Re: [R] structural equation modeling in sem, error, The model has negative degrees of freedom = -3, and The model is almost surely misspecified...
Dear Prof. John, I'm trying to solve the following model in R, but I getting error about the degree of freedom. As I don't have much experience, could you please explain to me what is the problem? I'm studying the influence of several soil parameters (pH, NH4, OM, Moisture) on the abundance of some microbial groups (Nitrosotalea, Nitrosos_Cl1, Nitrosos_Cl3, Nitrosos_Cl4 e Nitrosos_Cl7), and on enzyme activity (PNA). Thanks in advance, Best regards Michele mod.pnr1 - specifyModel() PD_AOA - PNA, B1, NA Nitrosotalea - PNA, B2, NA Nitrosos_Cl1 - PNA, B3, NA Nitrosos_Cl3 - PNA, B4, NA Nitrosos_Cl4 - PNA, B5, NA Nitrosos_Cl7 - PNA, B6, NA pH - PNA, B9, NA NH4 - PNA, B10, NA OM - PNA, B11, NA Moisture - PNA, B12, NA pH - PD_AOA, B18, NA NH4 - PD_AOA, B19, NA OM - PD_AOA, B20, NA Moisture - PD_AOA, B21, NA pH - Nitrosotalea, B22, NA NH4 - Nitrosotalea, B23, NA OM - Nitrosotalea, B24, NA Moisture - Nitrosotalea, B25, NA pH - Nitrosos_Cl1, B26, NA NH4 - Nitrosos_Cl1, B27, NA OM - Nitrosos_Cl1, B28, NA Moisture - Nitrosos_Cl1, B29, NA pH - Nitrosos_Cl3, B30, NA NH4 - Nitrosos_Cl3, B31, NA OM - Nitrosos_Cl3, B32, NA Moisture - Nitrosos_Cl3, B33, NA pH - Nitrosos_Cl4, B34, NA NH4 - Nitrosos_Cl4, B35, NA OM - Nitrosos_Cl4, B36, NA Moisture - Nitrosos_Cl4, B37, NA pH - Nitrosos_Cl7, B38, NA NH4 - Nitrosos_Cl7, B39, NA OM - Nitrosos_Cl7, B40, NA Moisture - Nitrosos_Cl7, B41, NA Nitrosotalea - Nitrosos_Cl1, B53, NA Nitrosotalea - Nitrosos_Cl3, B54, NA Nitrosotalea - Nitrosos_Cl4, B55, NA Nitrosotalea - Nitrosos_Cl7, B56, NA Nitrosos_Cl1 - Nitrosotalea, B57, NA Nitrosos_Cl1 - Nitrosos_Cl3, B58, NA Nitrosos_Cl1 - Nitrosos_Cl4, B59, NA Nitrosos_Cl1 - Nitrosos_Cl7, B60, NA Nitrosos_Cl3 - Nitrosotalea, B61, NA Nitrosos_Cl3 - Nitrosos_Cl1, B62, NA Nitrosos_Cl3 - Nitrosos_Cl4, B63, NA Nitrosos_Cl3 - Nitrosos_Cl7, B64, NA Nitrosos_Cl4 - Nitrosotalea, B65, NA Nitrosos_Cl4 - Nitrosos_Cl1, B66, NA Nitrosos_Cl4 - Nitrosos_Cl3, B67, NA Nitrosos_Cl4 - Nitrosos_Cl7, B68, NA Nitrosos_Cl7 - Nitrosotalea, B69, NA Nitrosos_Cl7 - Nitrosos_Cl1, B70, NA Nitrosos_Cl7 - Nitrosos_Cl4, B71, NA Nitrosos_Cl7 - Nitrosos_Cl3, B72, NA pH - NH4, B42, NA pH - OM, B43, NA NH4 - OM, B45, NA NH4 - pH, B46, NA OM - NH4, B47, NA OM - Moisture, B48, NA OM - pH, B52, NA Moisture - OM, B70, NA PNA - PNA, e12, NA PD_AOA - PD_AOA, NA, 1 Nitrosotalea - Nitrosotalea, e5, NA Nitrosos_Cl1 - Nitrosos_Cl1, e6, NA Nitrosos_Cl3 - Nitrosos_Cl3, e7, NA Nitrosos_Cl4 - Nitrosos_Cl4, e8, NA Nitrosos_Cl7 - Nitrosos_Cl7, e9, NA NH4 - NH4, e6, NA OM - OM, e5, NA Moisture - Moisture, e7, NA pH - pH, NA, 1 -- Dra. Michele de C�ssia Pereira e Silva Escola Superior de Agricultura Luiz de Queiroz (ESALQ)/ USP Departamento de Ci�ncia do Solo e Nutri��o de Plantas Laborat�rio de Microbiologia do Solo Av P�dua Dias, 11 CP 09 CEP-13400-970 Piracicaba - S�o Paulo [[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.
Re: [R] structural equation modeling in sem, error, The model has negative degrees of freedom = -3, and The model is almost surely misspecified...
Dear Michele, It's impossible to know without the data, since that's the only way to determine which variables in the model are observed and which are latent variables, but if there are negative df, then you're trying to estimate a model with more free parameters than there are moments (typically, covariances) among the observed variables. Clearly, such a model is necessarily underidentified. Additionally, I suggest that you use specifyEquations() in preference to specifyModel() to describe the model. That should prove simpler (but of course won't allow you to estimate an underidentified model). I hope this helps, John --- John Fox, Professor Chair, Sociology Graduate Programme McMaster University Hamilton, Ontario, Canada http://socserv.socsci.mcmaster.ca/jfox/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Michele Silva Sent: Thursday, September 04, 2014 2:58 PM To: r-help@r-project.org Subject: Re: [R] structural equation modeling in sem, error, The model has negative degrees of freedom = -3, and The model is almost surely misspecified... Dear Prof. John, I'm trying to solve the following model in R, but I getting error about the degree of freedom. As I don't have much experience, could you please explain to me what is the problem? I'm studying the influence of several soil parameters (pH, NH4, OM, Moisture) on the abundance of some microbial groups (Nitrosotalea, Nitrosos_Cl1, Nitrosos_Cl3, Nitrosos_Cl4 e Nitrosos_Cl7), and on enzyme activity (PNA). Thanks in advance, Best regards Michele mod.pnr1 - specifyModel() PD_AOA - PNA, B1, NA Nitrosotalea - PNA, B2, NA Nitrosos_Cl1 - PNA, B3, NA Nitrosos_Cl3 - PNA, B4, NA Nitrosos_Cl4 - PNA, B5, NA Nitrosos_Cl7 - PNA, B6, NA pH - PNA, B9, NA NH4 - PNA, B10, NA OM - PNA, B11, NA Moisture - PNA, B12, NA pH - PD_AOA, B18, NA NH4 - PD_AOA, B19, NA OM - PD_AOA, B20, NA Moisture - PD_AOA, B21, NA pH - Nitrosotalea, B22, NA NH4 - Nitrosotalea, B23, NA OM - Nitrosotalea, B24, NA Moisture - Nitrosotalea, B25, NA pH - Nitrosos_Cl1, B26, NA NH4 - Nitrosos_Cl1, B27, NA OM - Nitrosos_Cl1, B28, NA Moisture - Nitrosos_Cl1, B29, NA pH - Nitrosos_Cl3, B30, NA NH4 - Nitrosos_Cl3, B31, NA OM - Nitrosos_Cl3, B32, NA Moisture - Nitrosos_Cl3, B33, NA pH - Nitrosos_Cl4, B34, NA NH4 - Nitrosos_Cl4, B35, NA OM - Nitrosos_Cl4, B36, NA Moisture - Nitrosos_Cl4, B37, NA pH - Nitrosos_Cl7, B38, NA NH4 - Nitrosos_Cl7, B39, NA OM - Nitrosos_Cl7, B40, NA Moisture - Nitrosos_Cl7, B41, NA Nitrosotalea - Nitrosos_Cl1, B53, NA Nitrosotalea - Nitrosos_Cl3, B54, NA Nitrosotalea - Nitrosos_Cl4, B55, NA Nitrosotalea - Nitrosos_Cl7, B56, NA Nitrosos_Cl1 - Nitrosotalea, B57, NA Nitrosos_Cl1 - Nitrosos_Cl3, B58, NA Nitrosos_Cl1 - Nitrosos_Cl4, B59, NA Nitrosos_Cl1 - Nitrosos_Cl7, B60, NA Nitrosos_Cl3 - Nitrosotalea, B61, NA Nitrosos_Cl3 - Nitrosos_Cl1, B62, NA Nitrosos_Cl3 - Nitrosos_Cl4, B63, NA Nitrosos_Cl3 - Nitrosos_Cl7, B64, NA Nitrosos_Cl4 - Nitrosotalea, B65, NA Nitrosos_Cl4 - Nitrosos_Cl1, B66, NA Nitrosos_Cl4 - Nitrosos_Cl3, B67, NA Nitrosos_Cl4 - Nitrosos_Cl7, B68, NA Nitrosos_Cl7 - Nitrosotalea, B69, NA Nitrosos_Cl7 - Nitrosos_Cl1, B70, NA Nitrosos_Cl7 - Nitrosos_Cl4, B71, NA Nitrosos_Cl7 - Nitrosos_Cl3, B72, NA pH - NH4, B42, NA pH - OM, B43, NA NH4 - OM, B45, NA NH4 - pH, B46, NA OM - NH4, B47, NA OM - Moisture, B48, NA OM - pH, B52, NA Moisture - OM, B70, NA PNA - PNA, e12, NA PD_AOA - PD_AOA, NA, 1 Nitrosotalea - Nitrosotalea, e5, NA Nitrosos_Cl1 - Nitrosos_Cl1, e6, NA Nitrosos_Cl3 - Nitrosos_Cl3, e7, NA Nitrosos_Cl4 - Nitrosos_Cl4, e8, NA Nitrosos_Cl7 - Nitrosos_Cl7, e9, NA NH4 - NH4, e6, NA OM - OM, e5, NA Moisture - Moisture, e7, NA pH - pH, NA, 1 -- Dra. Michele de C�ssia Pereira e Silva Escola Superior de Agricultura Luiz de Queiroz (ESALQ)/ USP Departamento de Ci�ncia do Solo e Nutri��o de Plantas Laborat�rio de Microbiologia do Solo Av P�dua Dias, 11 CP 09 CEP-13400-970 Piracicaba - S�o Paulo [[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.
[R] structural equation modeling in sem, error, The model has negative degrees of freedom = -3, and The model is almost surely misspecified...
Hi all, I am attempting to learn my way through the sem package by constructing a simple structural model for some of my data on bird diversity, abundance, and primary productivity. I have constructed a covariance matrix between these variables as per the following: S_matrix = matrix(c( + 0.003083259, 0, 0, + 0.143870284, 89.7648490, 0, + 0.276950919, 81.3484101, 215.3570157 ), ncol = 3, byrow = T) rownames(S_matrix) = colnames(S_matrix) = c(dec_mean_EVI, density, ALL_Jack1) I then construct a model using a symbolic ram specification as follows tmodel - specify.model() dec_mean_EVI - density, gam1, NA density - ALL_Jack1, gam2, NA dec_mean_EVI - ALL_Jack1, gam3, NA dec_mean_EVI - dec_mean_EVI, ps1, NA density - density, ps2, NA ALL_Jack1 - ALL_Jack1, theta1, NA dec_mean_EVI - density, theta2, NA dec_mean_EVI - ALL_Jack1, theta2, NA density - ALL_Jack1, theta3, NA I then try to run the sem analysis using the matrix and model. sem_1 - sem(ram = tmodel, S = S_matrix, N = 88, fixed.x = c(dec_mean_EVI)) summary(sem_1) However, I only get the following error message: Error in sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars, : The model has negative degrees of freedom = -3 In addition: Warning message: In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars, : The following variables have no variance or error-variance parameter (double-headed arrow): density, ALL_Jack1, dec_mean_EVI, density, density, ALL_Jack1 The model is almost surely misspecified; check also for missing covariances. It must be obvious to those experienced with sem, but I can't yet see where I have gone wrong in constructing my matrix or model, any thoughts would be much appreciated. thanks in advance, Alex __ 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.
Re: [R] structural equation modeling in sem, error, The model has negative degrees of freedom = -3, and The model is almost surely misspecified...
Dear Alex, Your problem doesn't have much to do with the sem package. The model that you're trying to estimate is grossly underidentified. The model has 9 parameters to estimate and there are only 3*4/2 = 6 covariances among the 3 observed variables, hence the -3 df. There are also no exogenous variables in the model, since you specified that dec is correlated with the structural disturbances for density and ALL-Jack1. Regards, 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 Alex Anderson Sent: October-25-10 2:19 AM To: r-help@r-project.org Subject: [R] structural equation modeling in sem, error, The model has negative degrees of freedom = -3, and The model is almost surely misspecified... Hi all, I am attempting to learn my way through the sem package by constructing a simple structural model for some of my data on bird diversity, abundance, and primary productivity. I have constructed a covariance matrix between these variables as per the following: S_matrix = matrix(c( + 0.003083259, 0, 0, + 0.143870284, 89.7648490, 0, + 0.276950919, 81.3484101, 215.3570157 ), ncol = 3, byrow = T) rownames(S_matrix) = colnames(S_matrix) = c(dec_mean_EVI, density, ALL_Jack1) I then construct a model using a symbolic ram specification as follows tmodel - specify.model() dec_mean_EVI - density, gam1, NA density - ALL_Jack1, gam2, NA dec_mean_EVI - ALL_Jack1, gam3, NA dec_mean_EVI - dec_mean_EVI, ps1, NA density - density, ps2, NA ALL_Jack1 - ALL_Jack1, theta1, NA dec_mean_EVI - density, theta2, NA dec_mean_EVI - ALL_Jack1, theta2, NA density - ALL_Jack1, theta3, NA I then try to run the sem analysis using the matrix and model. sem_1 - sem(ram = tmodel, S = S_matrix, N = 88, fixed.x = c(dec_mean_EVI)) summary(sem_1) However, I only get the following error message: Error in sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars, : The model has negative degrees of freedom = -3 In addition: Warning message: In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars, : The following variables have no variance or error-variance parameter (double-headed arrow): density, ALL_Jack1, dec_mean_EVI, density, density, ALL_Jack1 The model is almost surely misspecified; check also for missing covariances. It must be obvious to those experienced with sem, but I can't yet see where I have gone wrong in constructing my matrix or model, any thoughts would be much appreciated. thanks in advance, Alex __ 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.