1
$\begingroup$

Intuitively, it seems like they would be doing the same thing, but I am getting different results between the two models. What is going on under the hood that would result in different coefficient estimates?

iris.lm <- lm(log(Sepal.Length) ~ log(Sepal.Width), data = iris)
summary(iris.lm)
#> 
#> Call:
#> lm(formula = log(Sepal.Length) ~ log(Sepal.Width), data = iris)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -0.2978 -0.1086 -0.0101  0.1022  0.3365 
#> 
#> Coefficients:
#>                  Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)       1.87727    0.09003  20.852   <2e-16 ***
#> log(Sepal.Width) -0.11005    0.08063  -1.365    0.174    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 0.1408 on 148 degrees of freedom
#> Multiple R-squared:  0.01243,    Adjusted R-squared:  0.005759 
#> F-statistic: 1.863 on 1 and 148 DF,  p-value: 0.1743

iris.glm <- glm(Sepal.Length ~ log(Sepal.Width), data = iris, family = gaussian(link = 'log'))
summary(iris.glm)
#> 
#> Call:
#> glm(formula = Sepal.Length ~ log(Sepal.Width), family = gaussian(link = "log"), 
#>     data = iris)
#> 
#> Deviance Residuals: 
#>     Min       1Q   Median       3Q      Max  
#> -1.5477  -0.6545  -0.1070   0.5612   2.1830  
#> 
#> Coefficients:
#>                  Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)       1.87111    0.09002  20.786   <2e-16 ***
#> log(Sepal.Width) -0.09562    0.08090  -1.182    0.239    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> (Dispersion parameter for gaussian family taken to be 0.6836385)
#> 
#>     Null deviance: 102.17  on 149  degrees of freedom
#> Residual deviance: 101.18  on 148  degrees of freedom
#> AIC: 372.62
#> 
#> Number of Fisher Scoring iterations: 4

Created on 2019-07-22 by the reprex package (v0.3.0)

$\endgroup$
  • $\begingroup$ These seem pretty close to me. Could be a difference in the fitting procedure. Have you tried running the optimization with more iterations or a higher tolerance? $\endgroup$ – Demetri Pananos Jul 22 at 17:22
  • $\begingroup$ The first model: log(y) follows normal. The second model: y follows normal. $\endgroup$ – user158565 Jul 22 at 17:32
  • $\begingroup$ @user158565 I'm not sure what you mean. Could you expound on that? $\endgroup$ – dylanjm Jul 22 at 21:23
0
$\begingroup$

All of the GLM(M) statistical models are established on the assumed distribution of response variable conditional on the given covariates. From specified distribution, the likelihood function is derived. By maximizing the (log) likelihood function, the maximum likelihood estimate (MLE) of the parameters is generated.

In this one lm(log(Sepal.Length) ~ log(Sepal.Width), data = iris) you specified that log(Sepal.Length) follows normal distribution, while in glm(Sepal.Length ~ log(Sepal.Width), data = iris, family = gaussian(link = 'log')) you specified Sepal.Length follows normal distribution.

Therefore you specified two different distributions, ==> two different likelihood functions ==> two sets of different estimate of the parameters.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.