If it is not standardized, I have the following script that I use to  
calculate the r^2 for each variable of a model.  I do wonder, however,  
if there is a way to calculate a model-wide r^2 like index.

-Jarrett

##
#returns the r^2 for endogenous variables and error path coefficients
#
# Last updated 8/18/08
##

rsquare.sem<-function (sem.obj){
        output.info<-list()
        
        for (index in 1:length(sem.obj$S[,1])){
                var.name<-sem.obj$var.names[index]
                obs.var<-sem.obj$S[index,index]
                est.var<-sem.obj$P[index,index]
                r.sq<-1-(est.var/obs.var)
                std.error.coef<-sqrt(1-r.sq)
                
                #if it's 0, or close to (due to rounding error), it's exogenous
                if(r.sq > 1e-10){
                output.info<-c(output.info, var.name, obs.var, est.var, r.sq,  
std.error.coef)
                }
                
        }
        
        output.matrix<-matrix(output.info, ncol=5, byrow=TRUE)
        colnames(output.matrix)<-c("Variable", "Observed.Variance",  
"Estimated.Variance", "R^2", "Standardized.Error.Coefficient")
        output.matrix
}





----------------------------------------
Jarrett Byrnes
Postdoctoral Associate, Santa Barbara Coastal LTER
Marine Science Institute
University of California Santa Barbara
Santa Barbara, CA 93106-6150
http://www.lifesci.ucsb.edu/eemb/labs/cardinale/people/byrnes/index.html

On Feb 9, 2010, at 4:17 AM, John Fox wrote:

> Dear Kathryn,
>
> I assume that MWDError is the error variance associated with MWD. If  
> MWD is
> a standardized variable (i.e., with a variance of 1) then 59% of its
> variance is unaccounted for.
>
> I hope this helps,
> John
>
> --------------------------------
> John Fox
> Senator William McMaster
>  Professor of Social Statistics
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> web: socserv.mcmaster.ca/jfox
>
>> -----Original Message-----
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
>> ]
> On
>> Behalf Of Kathryn Barto
>> Sent: February-09-10 6:23 AM
>> To: r-help@r-project.org
>> Subject: [R] interpreting error estimate in SEM
>>
>> hi,
>>
>> I'm using the sem package, and I want to make sure I'm interpreting  
>> the
>> output correctly. Here is an excerpt of my output. When I report  
>> the MWD
>> error, should I say that 59% of the variation in MWD is not  
>> explained by
> the
>> model, or that 59% of the variation is explained, or something  
>> entirely
>> different.
>>
>> Parameter Estimates
>>                   Estimate  Std Error z value  Pr(>|z|)
>> NplantRoots         0.462029   0.120803   3.82466 1.3095e-04    
>> plantRoots
> <--
>> - N
>> ...
>> CoError             1.000011 0.151850   6.58553 4.5325e-11 Co <--> Co
>> carbonateError      1.000009 0.156217   6.40142 1.5394e-10 carbonate
> <-->
>> carbonate
>> MWDError            0.589788   0.092128   6.40185 1.5351e-10    MWD  
>> <-->
> MWD
>>
>> Thanks
>> Kathryn
>>
>> ______________________________________________
>> R-help@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.
>
> ______________________________________________
> R-help@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.


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to