Hello: I have some trouble making a prediction from an AR(p) model. After I have the AR(p) model fitted , I want to use a new data set to make predictions. But I get the error: Error in newdata - object$x.mean : non-numeric argument to binary operator. A small version of my original data looks like: X1 X2 X3 X4 40813.65 1 10 41.86755 40813.65 1 8 41.86755 40813.66 1 8 41.86755 40813.66 1 8 41.86755 40813.66 1 8 41.86755 40813.67 1 8 41.86755 40813.67 1 6 41.86755 40813.67 1 6 41.86755 40813.68 1 6 41.86755 40813.68 1 6 41.86755 40813.73 1 4 41.86755 Sh<-read.table("C:\\ Desktop\\Sh.txt",sep=",",header=TRUE) model <- ar.yw(Sh[,3]) My new data looks like: X3 10 8 8 8 8 8 6 6 6 6 4 4 4 4 4 4 4 4 4 4 5 5 me<-read.table("C:\\Users\\351240\\Desktop\\me.txt",sep=",",header=TRUE) predict(model,me,n.ahead = 1) Then I get the error: Error in newdata - object$x.mean : non-numeric argument to binary operator. Can someone help me please. Thanks, Ana Lucia [[alternative HTML version deleted]]
Hi all, I have a data set containing dates in the format of m/d/y starting from 1950. I wanted to use standard format of date R uses. So I read the data set in R and converted it using as.Dates. But for dates from 1950-1968, I have the following problem. as.Date("1/1/50","%m/%d/%y",origin="1900/01/01") ="2050-01-01" instead of "1950-01-01" But for dates 1969 onwards it is working fine. as.Date("1/1/69","%m/%d/%y") = "1969-01-01" Can anyone please help me find out the problem? Thanks Shant [[alternative HTML version deleted]]
On Nov 20, 2011, at 10:46 PM, Shant Ch wrote:> > Hi all, > > > > I have a data set > containing dates in the format of m/d/y starting from 1950. I wanted > to > use standard format of date R uses. So I read the data set in R and > converted it using as.Dates. But for dates from 1950-1968, I have the > following problem. > > as.Date("1/1/50","%m/%d/%y",origin="1900/01/01") ="2050-01-01" > instead of "1950-01-01" > > But for dates 1969 onwards it is working fine.As is documented in ?strptime %y Year without century (00?99). On input, values 00 to 68 are prefixed by 20 and 69 to 99 by 19 ? that is the behaviour specified by the 2004 and 2008 POSIX standards, but they do also say ?it is expected that in a future version the default century inferred from a 2-digit year will change?.> > as.Date("1/1/69","%m/%d/%y") = "1969-01-01" >Perhaps some greppingg surgery? > as.Date(sub("(.+/.+/)([0-6])", "\\119\\2", "1/1/69"),"%m/%d/%Y") [1] "1969-01-01" You have not really described the problem completely .... what is the range of dates we need to work with? Do you have any "1/1/05" type values and if so what century should be assumed?> > Can anyone please help me find out the problem? > > Thanks > Shant > [[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.David Winsemius, MD West Hartford, CT
I have a model like this (Nelson and Siegel 1987) <img src="http://r.789695.n4.nabble.com/file/n4120161/31f188c684764cd431619dbb59fed5ae.png" border="0"/> where tau and y are the maturities and yields, respectively, given to me in my data file.. y<-c(4.863,5.662,6.41,6.864,7.153,7.352,7.409,7.474,7.503,7.644,7.676,7.701,7.674,7.668,7.665,7.741,7.743,7.742) tau<-c(1,3,6,9,12,15,18,21,24,30,36,48,60,72,84,96,108,120) I firstly need to find the MLE of m which maximises the likelihood function and then I can easily find the b1, b2 and b3 constants using this m value via least squares estimation.. But does anybody know how I can go abouts finding the MLE of m and if you could help with providing r code for it, I would appreciate that a lot. I have been pulling my hair out for the past week now trying to do it :) [[alternative HTML version deleted]]