Federico Tamagni
2007-Mar-28 08:57 UTC
[R] nlsystemfit: Errors with reproducing the manual example
Hi everybody, I'm a newbye with lots of problems :). I'm trying to use nlsystemfit, but I recieve two error messages whose origin that I don't understand. 1) When I try to reproduce the example reported in the systemfit package manual, that is library( systemfit ) data( ppine ) hg.formula <- hg ~ exp( h0 + h1*log(tht) + h2*tht^2 + h3*elev + h4*cr) dg.formula <- dg ~ exp( d0 + d1*log(dbh) + d2*hg + d3*cr + d4*ba ) labels <- list( "height.growth", "diameter.growth" ) inst <- ~ tht + dbh + elev + cr + ba start.values <- c(h0=-0.5, h1=0.5, h2=-0.001, h3=0.0001, h4=0.08, + d0=-0.5, d1=0.009, d2=0.25, d3=0.005, d4=-0.02 ) model <- list( hg.formula, dg.formula ) model.ols <- nlsystemfit( "OLS", model, start.values, data=ppine, eqnlabels=labels ) then I get the following messages: / The following object(s) are masked _by_ .GlobalEnv : dg hg The following object(s) are masked from data ( position 3 ) : ba cr dbh dg elev hg smi tht Error in array(x, c(length(x), 1), if (!is.null(names(x))) list(names(x), : dim<- : invalid first argument / 2) When I try to do something similar on my own data (called R_manuf and containing 3 columns named va98, ts98 and gom98) with the code library(systemfit) dati <- read.table("R_manuf",header=T,na.strings="nan") attach(dati) y1 <- va98/ts98 - 1; y2 <- gom98 - va98; eq1.formula <- y1.98 ~ a1*ts98^(b1-1) ; eq2.formula <- y2.98 ~ a2*ts98^b2 ; labels <- list("eq1", "eq2" ); start.values <- c(a1=-0.5, b1=1.02, a2=-0.8, b2=0.9 ); model <- list( eq1.formula, eq2.formula); model.ols <- nlsystemfit( "OLS", model, start.values, eqnlabels=labels ); print(model.ols); then I get a different error message: / Error in eval(expr, envir, enclos) : incorrect number of subscripts on matrix/ Thanks for your help, Federico -- Federico Tamagni, PhD student LEM - Laboratory of Economics and Management Scuola Superiore Sant'Anna, Pisa, Italy Phone: (+39)-050-883341 Fax: (+39)-050-883344 email: f.tamagni at sssup.it website: https://mail.sssup.it/~f.tamagni/