Doing linear prediction with R: How to access the predicted parameter(s)?

I am new to R and I am trying to do linear prediction. Here is some simple data:

test.frame<-data.frame(year=8:11, value= c(12050,15292,23907,33991))

Say if I want to predict the value for year=12. This is what I am doing (experimenting with different commands):

lma=lm(test.frame$value~test.frame$year)  # let's get a linear fit
summary(lma)                              # let's see some parameters
attributes(lma)                           # let's see what parameters we can call
lma$coefficients                          # I get the intercept and gradient
newyear <- 12                             # new value for year
predict.lm(lma, newyear)                  # predicted value for the new year

Some queries:

  1. if I issue the command lma$coefficients for instance, a vector of two values is returned to me. How to pick only the intercept value?

  2. I get lots of output with predict.lm(lma, newyear) but cannot understand where the predicted value is. Can someone please clarify?

Thanks a lot...




Predict, try this:

test.frame <- data.frame(year=12, value=0)
predict.lm(lma, test.frame)   

Need Your Help

Change splitter position for contentPane in borderContainer?

dojo contentpane border-container

I have 2 contentPanes inside a BorderContainer using the Dojo Toolkit. Much like the following:

Requiring users to update .NET

c# .net linq client-applications

I'm working on some production software, using C# on the .NET framework. I really would like to be able to use LINQ on the project. I believe it requires .NET version 3.5 (correct me if I'm wrong)....

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.