[R] function that join my model & these coefficients

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sun Jul 27 18:39:39 CEST 2014


You should study the theory of regression before proceeding, since the chance of obtaining a significant (useful) result with 400 inputs is negligible.

You should also read the help files for the functions you are using (e.g. ?lm), which in this case mention the coef() function in the See Also section.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On July 27, 2014 2:08:25 AM PDT, Maede Nouri <maede_nourii at yahoo.com> wrote:
>hello�
>I am new to R language.�I fitted a linear model and my output has about
>300 coefficients. I need to definition a function that join my model &
>these coefficients ! this is difficult because number of�coefficients
>is many.�
>I think there is not�a�provided query for this. I also used
>"fitted(fit) # predicted values" but it can't help me to recieve my
>goal. please help me�in finding the functions and�merge�my model�& its
>coefficients.
>
>
>data2<-subset(data1,pd2<660000)
>> sapply(data2,mode)
>� � � � aid � � � � act � � � �acid � � �id_new � � �userid � � � � pd1
>� � � � pd2 � � � � pd3 � � � � pd4 � � � � pd5 � � � freq1 � � � freq2
>� � � freq3�
>� "numeric" � "numeric" � "numeric" � "numeric" "character" "character"
>"character" "character" "character" � "numeric" � "numeric" � "numeric"
>� "numeric"�
>� � � freq4 � � � freq5�
>� "numeric" � "numeric"�
>> fit <- lm(act
>~freq1+freq2+freq3+freq4+freq5+pd1*freq1+pd2*freq2+pd3*freq3+pd4*freq4+pd5*freq5-1,data=data2)
>> summary(fit)
>
>Call:
>lm(formula = act ~ freq1 + freq2 + freq3 + freq4 + freq5 + pd1 *�
>� � freq1 + pd2 * freq2 + pd3 * freq3 + pd4 * freq4 + pd5 * freq5 -�
>� � 1, data = data2)
>
>Residuals:
>� � Min � � �1Q �Median � � �3Q � � Max�
>-26.905 �-2.843 � 0.000 � 1.606 �33.059�
>
>Coefficients: (233 not defined because of singularities)
>� � � � � � � � � Estimate Std. Error t value Pr(>|t|) � �
>freq1 � � � � � �1.293e-01 �1.753e-01 � 0.738 0.461206 � �
>freq2 � � � � � �2.016e-01 �3.310e-01 � 0.609 0.542809 � �
>freq3 � � � � � -4.816e+00 �2.220e+00 �-2.169 0.030795 * �
>freq4 � � � � � �2.395e-01 �1.751e+00 � 0.137 0.891272 � �
>freq5 � � � � � -9.289e+00 �6.110e+00 �-1.520 0.129394 � �
>pd1630000 � � � �5.625e+00 �5.978e+00 � 0.941 0.347445 � �
>pd1646000 � � � �7.082e+00 �1.410e+01 � 0.502 0.615714 � �
>pd1648000 � � � �1.275e+00 �4.240e+01 � 0.030 0.976027 � �
>pd1651000 � � � �3.404e+00 �5.694e+00 � 0.598 0.550352 � �
>pd1656000 � � � -8.177e+00 �1.017e+01 �-0.804 0.421906 � �
>pd1665000 � � � �3.795e+00 �5.649e+00 � 0.672 0.502231 � �
>pd1666000 � � � �9.805e+00 �5.857e+00 � 1.674 0.095058 . �
>pd2651000 � � � �4.790e+00 �6.122e+00 � 0.782 0.434510 � �
>pd2656000 � � � �1.754e+00 �5.620e+00 � 0.312 0.755221 � �
>pd2659000 � � � �4.187e-01 �9.814e+00 � 0.043 0.965996 � �
>pd3630000 � � � -7.989e+00 �5.629e+00 �-1.419 0.156780 � �
>pd3646000 � � � -1.638e+00 �1.772e+01 �-0.092 0.926444 � �
>pd3648000 � � � -4.021e+00 �7.725e+00 �-0.521 0.602998 � �
>pd3651000 � � � -4.848e+00 �6.400e+00 �-0.758 0.449243 � �
>pd3656000 � � � -6.105e-01 �8.732e+00 �-0.070 0.944303 � �
>pd3659000 � � � �4.474e+00 �7.483e+00 � 0.598 0.550296 � �
>pd3663000 � � � �1.299e+02 �4.969e+01 � 2.614 0.009360 **�
>pd3737082 � � � � � � � NA � � � � NA � � �NA � � � NA � �
>pd3737110 � � � �9.847e+01 �3.120e+01 � 3.156 0.001744 **�
>pd3738240 � � � �5.675e+00 �1.223e+01 � 0.464 0.643073 � �
>pd4646000 � � � �8.603e+00 �1.751e+01 � 0.491 0.623605 � �
>pd4648000 � � � �3.040e+00 �4.848e+00 � 0.627 0.531064 � �
>pd4651000 � � � �9.141e-01 �5.243e+00 � 0.174 0.861689 � �
>pd5 � � � � � � �1.132e-06 �3.440e-06 � 0.329 0.742355 � �
>freq1:pd1646000 � � � � NA � � � � NA � � �NA � � � NA � �
>freq1:pd1648000 -1.786e+00 �1.267e+01 �-0.141 0.888002 � �
>freq2:pd2646000 �1.369e+01 �1.666e+01 � 0.822 0.411865 � �
>freq2:pd2648000 �1.396e+00 �2.172e+00 � 0.643 0.520933 � �
>freq3:pd3693000 �3.270e+00 �2.557e+00 � 1.279 0.201910 � �
>freq3:pd3694000 �7.476e+00 �3.571e+00 � 2.094 0.037035 * �
>freq3:pd3699000 �5.310e+00 �2.187e+00 � 2.429 0.015679 * �
>
>
>thank you
>	[[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.



More information about the R-help mailing list