[R] nlrwr package. Error when fitting the optimal Box-Cox transformation with two variables

Ikerne del Valle ikerne.delvalle at ehu.es
Tue May 19 17:17:58 CEST 2009



	Dear all:

	I'm trying to fit the optimal Box-Cox 
transformation related to nls (see the code 
below) for the demand of money data in Green (3th 
Edition) but in the last step R gives the next 
error message.
	Error en 
`[.data.frame`(eval(object$data), , 
as.character(formula(object)[[2]])[2]) :
   undefined columns selected.
	¿Any idea to solve the problem?
	Thanks in advance,


library(nlrwr)
r<-c(4.50,4.19,5.16,5.87,5.95,4.88,4.50,6.44,7.83,6.25,5.50,5.46,7.46,10.28,11.77,13.42,11.02,8.50,8.80,7.69)
M<-c(480.00,524.30,566.30,589.50,628.20,712.80,805.20,861.00,908.40,1023.10,1163.60,1286.60,1388.90,1497.90,1631.40,1794.40,1954.90,2188.80,2371.70,2563.60)
Y<-c(2208.30,2271.40,2365.60,2423.30,2416.20,2484.80,2608.50,2744.10,2729.30,2695.00,2826.70,2958.60,3115.20,3192.40,3187.10,3248.80,3166.00,3277.70,3492.00,3573.50)
money<-data.frame(r,M,Y)
attach(money)
ols1<-lm(log(M)~log(r)+log(Y))
output1<-summary(ols1)
coef1<-ols1$coefficients
a1<-coef1[[1]]
b11<-coef1[[2]]
b21<-coef1[[3]]
money.m1<-nls(log(M)~a+b*r^g+c*Y^g,data=money,start=list(a=a1,b=b11,g=1,c=b21))
summary(money.m1)
money.m2<-boxcox(money.m1)



	Prof. Ikerne del Valle Erkiaga
		Department of Applied Economics V
		Faculty of Economic and Business Sciences
		University of the Basque Country
		Avda. Lehendakari Agirre, Nº 83
		48015 Bilbao (Bizkaia) Spain




More information about the R-help mailing list