If we want more covariates, do we add rows or more code?
Or I mean more lines of code?
If we want more covariates, do we add rows or more code?
Or I mean more lines of code?
you might want to add more lines in the script that create additional objects
rather than extra rows in a matrix
So if I wanted to add one for country I would set up all four lines of that code for country?
you can follow the came pattern so
mean = intercept + b*sex + b*age + b*season etc
With multiple covariates, you can create a regression equation like Sarah showed.
You can also create a matrix expression like
mean = B %*% x
where mean is a vector of expected means, B is a matrix of regression coefficients, and x is a vector of definition variables.
Could you give some example code, I’m having trouble visualize that
I will warn you, covarying out country can get gnarly…if you have k countries represented in your dataset, you will need k-1 dummy variables (or however you want to code it).
I was just giving an example, I just want to know how to set up several covariates. As an alternative to regressing them out first
Here’s some OpenMx-ish code that does the matrix approach
mxMatrix('Full', nrow=3, ncol=1, values=c(1, NA, NA), labels=c(NA, 'data.Covariate1', 'data.Covariate2'), name='x')
mxMatrix('Full', nrow=2, ncol=3, free=TRUE, name='B')
mxAlgebra(B %*% x, name='expectedMean') # 2 rows, 1 column