An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121012/ca960e4f/attachment.pl>
Error in rowMeans function
4 messages · Gunsalus, Catherine, PIKAL Petr, yrosseel
2 days later
Hi
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Gunsalus, Catherine
Sent: Friday, October 12, 2012 8:52 PM
To: r-help at r-project.org
Subject: [R] Error in rowMeans function
Hello,
I am trying to create parcels for a CFA model. I am trying to average
6 sets of 3 variables each into parcels. I don't understand why I am
getting an error message as follows:
Thanks for your help,
Catherine
atds1par <- rowMeans(semHW1dat1[, c("atds1", "atds2", "atds3")],
na.rm=TRUE)
atds2par <- rowMeans(semHW1dat1[, c("atds4", "atds5", "atds6")],
na.rm=TRUE)
atds3par <- rowMeans(semHW1dat1[, c("atds7", "atds8", "atds9")],
na.rm=TRUE)
sgs1par <- rowMeans(semHW1dat1[, c("sgs1", "sgs2", "sgs3")],
na.rm=TRUE)
sgs2par <- rowMeans(semHW1dat1[, c("sgs4", "sgs5", "sgs6")],
na.rm=TRUE)
sgs3par <- rowMeans(semHW1dat1[, c("sgs7", "sgs8", "sgs9")],
na.rm=TRUE)
parmod1 <- "ProDragATT =~ atds1par + atds2par + atds3par
+ SucInSchl =~ sgs1par + sgs2par + sgs3par + ProDragAtt~~SucInSchl"
are you sure about =~ and ~~ is valid in specifying formula? I am not avare of cfa but it does not seem to be in accordance with all other formulas i know.
parout1 <- cfa(parmod1, data=semHW1dat1, sample.nobs=500,
std.lv=TRUE) Error in getDataFull(data = data, group = group, group.label = group.label, : lavaan ERROR: missing observed variables in dataset: atds1par atds2par atds3par sgs1par sgs2par sgs3par ProDragAtt
Are your data semHW1dat1 structured as required by cfa? Somehow cfa function missed your atds1par and other variables which are outside of data frame. Maybe the function requires them to be included in data frame. All following errors are due to cfa did not evaluated the model. Regards Petr
summary(parout1)
Error in summary(parout1) : error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'parout1' not found
fitMeasures(parout1)
Error in fitMeasures(parout1) : object 'parout1' not found
inspect(parout1, "mi")
Error in inspect(parout1, "mi") : error in evaluating the argument 'object' in selecting a method for function 'inspect': Error: object 'parout1' not found
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
On 10/15/2012 08:28 AM, PIKAL Petr wrote:
Hi
-----Original Message----- From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r- project.org] On Behalf Of Gunsalus,
Catherine Sent: Friday, October 12, 2012 8:52 PM To:
r-help at r-project.org Subject: [R] Error in rowMeans function
Hello, I am trying to create parcels for a CFA model. I am trying
to average 6 sets of 3 variables each into parcels. I don't
understand why I am getting an error message as follows: Thanks for
your help, Catherine
atds1par <- rowMeans(semHW1dat1[, c("atds1", "atds2", "atds3")],
na.rm=TRUE)
atds2par <- rowMeans(semHW1dat1[, c("atds4", "atds5", "atds6")],
na.rm=TRUE)
atds3par <- rowMeans(semHW1dat1[, c("atds7", "atds8", "atds9")],
na.rm=TRUE)
sgs1par <- rowMeans(semHW1dat1[, c("sgs1", "sgs2", "sgs3")],
na.rm=TRUE)
sgs2par <- rowMeans(semHW1dat1[, c("sgs4", "sgs5", "sgs6")],
na.rm=TRUE)
sgs3par <- rowMeans(semHW1dat1[, c("sgs7", "sgs8", "sgs9")],
na.rm=TRUE)
The cfa() function requires that all variables that are specified in the model syntax are included in a data.frame. So after constructing your parcels, you need to create a new data.frame containing them: Data <- data.frame(ads1par=atds1par, atds2par=atds2par, atds3par=atds3par, sgs1par=sgs1par, sgs2par=sgs2par, sgs3par=sgs3par) then, you can call the cfa() function but with 'Data' as your data argument (note: no need to provide sample.nobs, we get it from the data.frame): parout1 <- cfa(parmod1, data=Data, std.lv=TRUE) Hope this helps, Yves http://lavaan.org
Hi I did not use cfa function, the former poster (Catherine)did and I only advised almost the same as you did. Regards Petr
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of yrosseel Sent: Monday, October 15, 2012 8:40 AM To: r-help at r-project.org Subject: Re: [R] Error in rowMeans function On 10/15/2012 08:28 AM, PIKAL Petr wrote:
Hi
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of Gunsalus, Catherine Sent: Friday, October 12, 2012 8:52 PM To: r-help at r-project.org Subject: [R] Error in rowMeans function Hello, I am trying to create parcels for a CFA model. I am trying
to
average 6 sets of 3 variables each into parcels. I don't understand
why I am getting an error message as follows: Thanks for your help,
Catherine
atds1par <- rowMeans(semHW1dat1[, c("atds1", "atds2", "atds3")],
na.rm=TRUE)
atds2par <- rowMeans(semHW1dat1[, c("atds4", "atds5", "atds6")],
na.rm=TRUE)
atds3par <- rowMeans(semHW1dat1[, c("atds7", "atds8", "atds9")],
na.rm=TRUE)
sgs1par <- rowMeans(semHW1dat1[, c("sgs1", "sgs2", "sgs3")],
na.rm=TRUE)
sgs2par <- rowMeans(semHW1dat1[, c("sgs4", "sgs5", "sgs6")],
na.rm=TRUE)
sgs3par <- rowMeans(semHW1dat1[, c("sgs7", "sgs8", "sgs9")],
na.rm=TRUE)
The cfa() function requires that all variables that are specified in the model syntax are included in a data.frame. So after constructing your parcels, you need to create a new data.frame containing them: Data <- data.frame(ads1par=atds1par, atds2par=atds2par, atds3par=atds3par, sgs1par=sgs1par, sgs2par=sgs2par, sgs3par=sgs3par) then, you can call the cfa() function but with 'Data' as your data argument (note: no need to provide sample.nobs, we get it from the data.frame): parout1 <- cfa(parmod1, data=Data, std.lv=TRUE) Hope this helps, Yves http://lavaan.org
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.