Error when trying to get residuals

39 views
Skip to first unread message

Sara Bock

unread,
May 22, 2022, 5:09:18 PM5/22/22
to brainGraph-help
Dear Chris, 
I am referencing the complete code block on page 35 of the user guide in order to do structural covariance network analysis. I am using the DK atlas and cortical thickness, and brainGraph version 3.0.2 and R version 4.1.2 I have been able to successfully import the data and variables using the following code: 

datadir <- /home/rstudio/braingraphfiles
raw_data <- import_scn(datadir, atlas='dk', modality='thickness')
invisible(lapply(seq_along(raw_data), function(x)
assign(names(raw_data)[x], eval(raw_data[[x]]), envir=.GlobalEnv)))
covars <- fread(file.path(/home/rstudio/braingraphfiles, 'covars.csv'))
grps <- covars[, levels(factor(Group))] 

I am running into an error trying to get the residuals. When I run the following line: myResids <- get.resid(lhrh, covars=covars, exclude.cov='Group') I receive an error that says: Error in X %*% beta : non-conformable arguments.

My covars data frame contains 2,603 observations and 8 variables while my lhrh data frame contains 2,603 observations and 69 variables. 
From my understanding, this error is usually a matrix multiplication error, so I tried to transpose the covars file so the number of columns in one df matched the number of rows in the other. I also temporarily altered the lhrh df to have 8 variables and exactly match the dimensions of the covars df. However I am still receiving the same error. 

What do you advise to address this error? 
Thank you so much, 
Sara

Chris Watson

unread,
Nov 28, 2022, 10:39:17 AM11/28/22
to brainGr...@googlegroups.com
I'm sorry for such a long delay in replying. If this is still a problem, I would need the actual data and code to replicate your error.

Are you sure you're running brainGraph v3.0.2? I'm pretty sure all occurrences of "beta" in "get.resid" were removed in v3.0.0.

Chris

--
You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-he...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/3a9f9d34-5345-4bb6-af14-a56bafd3178dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages