Re: [Fwd: Re: Fw: [R] Contour plot]

2005-02-10 Thread Petr Pikal


On 9 Feb 2005 at 16:32, [EMAIL PROTECTED] wrote:

 Petr,
 
 It works perfectly! But I still have a question;
 
 I have fit the following data;
 
 x,y,z
 1,10,11
 2,11,15
 3,12,21
 4,13,29
 5,14,39
 6,15,51
 7,16,65
 8,17,81
 9,18,99
 10,19,119
 
 dat.lm - lm(z~I(x^2)+y, data=dat)
 dat.lm
 
 Call:
 lm(formula = z ~ I(x^2) + y, data = dat)
 
 Coefficients:
 (Intercept)   I(x^2)y
   1.841e-141.000e+001.000e+00
 
 How do I create the z matrix from dat.lm?? Without having to type
 over all the coefficients?

Maybe
expand.grid() and predict()

# new data
x-1:10
y-20:60

new.df-expand.grid(x,y) #make data.frame
names(new.df)-c(x,y) #change to propper names

contour(x,y,matrix(predict(dat.lm, new.df),10,41))

Cheers
Petr



 
 Kind regards, Darius Blaszijk
 
 - Oorspronkelijk bericht
 - Onderwerp: Re: Fw: [R] Contour plot Van:
   Petr Pikal [EMAIL PROTECTED] Datum: Wo, 9 februari,
 2005 11:23 am Aan:   [EMAIL PROTECTED]
r-help@stat.math.ethz.ch
 --
 
 
 Hi Darius
 
 
 On 8 Feb 2005 at 17:43, [EMAIL PROTECTED] wrote:
 
  I understand that I need to have a (in this case) square matrix with
  all
 the data. But the question now is;
 
  - can the contourplot not interpolate the missing values
 
  or alternatively
 
  - I have fit a model to the z data (z = 100 + 0.5x + 0.5y). How can
  I
 make from this model a square matrix z to make a contour plot?
 
 
 Will
 
 x-1:10
 y-1:10
 z - outer(x,y,function(x,y) 100 + 0.5*x + 0.5*y)
 contour(x,y,z)
 
 work as you wish?
 Cheers
 Petr
 
 
 
  Kind regards, Darius Blaszijk
 
  - Original Message -
  From: Achim Zeileis [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Cc: r-help@stat.math.ethz.ch
  Sent: Tuesday, February 08, 2005 1:51 AM
  Subject: Re: [R] Contour plot
 
 
   On Tue, 8 Feb 2005 01:15:06 +0100 [EMAIL PROTECTED] wrote:
  
Hello,
   
I would like to make a contourplot of the following data;
   
 x - 1:10
 y - 1:10
 z - 100:110
   
By doing contour(x,y,z) I get the following error;
   
Error in contour.default(x, y, z) : no proper `z' matrix
specified
   
How do I fix this??
  
   x and y specify a grid and thus z must provide a value for each
 combination of the x's and y's! For example:
 x - y - 1:10
 contour(x, y, outer(x, y))
   Also look at
 outer(x, y)
   and read ?contour.
  
   Z
  
Kind regards, Datius Blaszijk
   
[[alternative HTML version deleted]]
   
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
   
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 Petr Pikal
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [Fwd: Re: Fw: [R] Contour plot]

2005-02-09 Thread Adaikalavan Ramasamy
How about data.lm$model ?


On Wed, 2005-02-09 at 16:32 +0100, [EMAIL PROTECTED] wrote:
 Petr,
 
 It works perfectly! But I still have a question;
 
 I have fit the following data;
 
 x,y,z
 1,10,11
 2,11,15
 3,12,21
 4,13,29
 5,14,39
 6,15,51
 7,16,65
 8,17,81
 9,18,99
 10,19,119
 
 dat.lm - lm(z~I(x^2)+y, data=dat)
 dat.lm
 
 Call:
 lm(formula = z ~ I(x^2) + y, data = dat)
 
 Coefficients:
 (Intercept)   I(x^2)y
   1.841e-141.000e+001.000e+00
 
 How do I create the z matrix from dat.lm?? Without having to type over
 all the coefficients?
 
 Kind regards, Darius Blaszijk
 
 - Oorspronkelijk bericht -
 Onderwerp: Re: Fw: [R] Contour plot
 Van:   Petr Pikal [EMAIL PROTECTED]
 Datum: Wo, 9 februari, 2005 11:23 am
 Aan:   [EMAIL PROTECTED]
r-help@stat.math.ethz.ch
 --
 
 Hi Darius
 
 
 On 8 Feb 2005 at 17:43, [EMAIL PROTECTED] wrote:
 
  I understand that I need to have a (in this case) square matrix with all
 the data. But the question now is;
 
  - can the contourplot not interpolate the missing values
 
  or alternatively
 
  - I have fit a model to the z data (z = 100 + 0.5x + 0.5y). How can I
 make from this model a square matrix z to make a contour plot?
 
 
 Will
 
 x-1:10
 y-1:10
 z - outer(x,y,function(x,y) 100 + 0.5*x + 0.5*y)
 contour(x,y,z)
 
 work as you wish?
 Cheers
 Petr
 
 
 
  Kind regards, Darius Blaszijk
 
  - Original Message -
  From: Achim Zeileis [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Cc: r-help@stat.math.ethz.ch
  Sent: Tuesday, February 08, 2005 1:51 AM
  Subject: Re: [R] Contour plot
 
 
   On Tue, 8 Feb 2005 01:15:06 +0100 [EMAIL PROTECTED] wrote:
  
Hello,
   
I would like to make a contourplot of the following data;
   
 x - 1:10
 y - 1:10
 z - 100:110
   
By doing contour(x,y,z) I get the following error;
   
Error in contour.default(x, y, z) : no proper `z' matrix
specified
   
How do I fix this??
  
   x and y specify a grid and thus z must provide a value for each
 combination of the x's and y's! For example:
 x - y - 1:10
 contour(x, y, outer(x, y))
   Also look at
 outer(x, y)
   and read ?contour.
  
   Z
  
Kind regards, Datius Blaszijk
   
[[alternative HTML version deleted]]
   
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
   
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 Petr Pikal
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html