Fikri Dwi Alpian - 120450022 - RB

Nomor 14.8

Input dataset

library(readxl)
## Warning: package 'readxl' was built under R version 4.2.2
df = read_excel("C:/Users/Acer A514-53/Downloads/model linear.xlsx")

Linear Model

# Linear Model
models1 <- lm(`population` ~ Time, data = df)
summary(models1)
## 
## Call:
## lm(formula = population ~ Time, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.20045 -0.50442 -0.01285  0.59852  1.30369 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 201.97274    0.27173   743.3   <2e-16 ***
## Time          2.32849    0.01531   152.1   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7256 on 28 degrees of freedom
## Multiple R-squared:  0.9988, Adjusted R-squared:  0.9987 
## F-statistic: 2.314e+04 on 1 and 28 DF,  p-value: < 2.2e-16
models1
## 
## Call:
## lm(formula = population ~ Time, data = df)
## 
## Coefficients:
## (Intercept)         Time  
##     201.973        2.328
# Yt= 201.972 + 2.328 t
# r^2 = 0.9988

Modelnya Yt = 201.972 + 2.328 t r-squared = 0.9988

Log Linear Model

# Log Linear Model
models2 <- lm(log(`population`) ~ Time, data = df)
summary(models2)
## 
## Call:
## lm(formula = log(population) ~ Time, data = df)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0035723 -0.0007549 -0.0002391  0.0008144  0.0033002 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 5.317e+00  6.084e-04    8739   <2e-16 ***
## Time        9.801e-03  3.427e-05     286   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.001625 on 28 degrees of freedom
## Multiple R-squared:  0.9997, Adjusted R-squared:  0.9996 
## F-statistic: 8.179e+04 on 1 and 28 DF,  p-value: < 2.2e-16
models2
## 
## Call:
## lm(formula = log(population) ~ Time, data = df)
## 
## Coefficients:
## (Intercept)         Time  
##    5.317035     0.009801
# ln Yt = 5.3170 + 0.0098t
# r^2 = 0.9997

Modelnya Yt = 5.3170 + 0.0098t r-squared = 0.9997

Logistik Model

# Logistik Growth Model
models3 <- nls(`population` ~ SSlogis(Time, phi1, phi2, phi3), data = df)
summary(models3)
## 
## Formula: population ~ SSlogis(Time, phi1, phi2, phi3)
## 
## Parameters:
##      Estimate Std. Error t value Pr(>|t|)    
## phi1 1574.951    635.529   2.478   0.0198 *  
## phi2  165.300     52.016   3.178   0.0037 ** 
## phi3   86.638      6.263  13.833 8.99e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3537 on 27 degrees of freedom
## 
## Number of iterations to convergence: 0 
## Achieved convergence tolerance: 3.658e-06
models3
## Nonlinear regression model
##   model: population ~ SSlogis(Time, phi1, phi2, phi3)
##    data: df
##    phi1    phi2    phi3 
## 1574.95  165.30   86.64 
##  residual sum-of-squares: 3.378
## 
## Number of iterations to convergence: 0 
## Achieved convergence tolerance: 3.658e-06
# Yt = 1574.95 / (1+3.658e-6)

Modelnya Yt = 1574.95 / (1+3.658e-6)

Nomor 14.9

Input dataset

df2 = read_excel("C:/Users/Acer A514-53/Downloads/14.9modellinear.xlsx")

Cobb-Douglas

Log linear

model <- lm(log(GDP) ~ log(Labor) + log(Capital), data=df2)
summary(model)
## 
## Call:
## lm(formula = log(GDP) ~ log(Labor) + log(Capital), data = df2)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.057144 -0.016249 -0.005791  0.023511  0.038740 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.65242    0.60620  -2.726   0.0144 *  
## log(Labor)    0.33973    0.18569   1.830   0.0849 .  
## log(Capital)  0.84600    0.09335   9.062 6.42e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02829 on 17 degrees of freedom
## Multiple R-squared:  0.9951, Adjusted R-squared:  0.9945 
## F-statistic:  1719 on 2 and 17 DF,  p-value: < 2.2e-16
model
## 
## Call:
## lm(formula = log(GDP) ~ log(Labor) + log(Capital), data = df2)
## 
## Coefficients:
##  (Intercept)    log(Labor)  log(Capital)  
##      -1.6524        0.3397        0.8460
# Modelnya
# ln GDP = -1.6524 + 0.3397 ln Labor + 0.8460 ln Capital 
# R-Squared = 0.9951

ln GDP = -1.6524 + 0.3397 ln Labor + 0.8460 ln R-Squared = 0.9951

14.1.4

# 14.1.4
# Cobb-Douglass (C-D) Function multiplicative error
models = nls(GDP ~ A*Labor + Capital*(1-a), 
             data=df2, start = list(A = 1, a = 0.5))
a = coef(models)
summary(models) # A=1.12328, a=0.39346, 1-a=0.60654
## 
## Formula: GDP ~ A * Labor + Capital * (1 - a)
## 
## Parameters:
##   Estimate Std. Error t value Pr(>|t|)    
## A  1.12328    0.72784   1.543     0.14    
## a  0.39346    0.02274  17.301 1.16e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6771 on 18 degrees of freedom
## 
## Number of iterations to convergence: 1 
## Achieved convergence tolerance: 1.647e-07

A=1.12328, a=0.39346, 1-a=0.60654

14.1.2

# 14.1.2
# Cobb-Douglass (C-D) Function additive error
models = nls(GDP ~ A*Labor**a*Capital**(1-a), 
             data=df2, start = list(A = 1, a = 0.5))
b = coef(models)
summary(models) # A=0.80529, a=0.06520, 1-a=0.9384
## 
## Formula: GDP ~ A * Labor^a * Capital^(1 - a)
## 
## Parameters:
##   Estimate Std. Error t value Pr(>|t|)    
## A  0.80529    0.09891   8.142 1.91e-07 ***
## a  0.06520    0.03509   1.858   0.0796 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6592 on 18 degrees of freedom
## 
## Number of iterations to convergence: 6 
## Achieved convergence tolerance: 1.558e-06

A=0.80529, a=0.06520, 1-a=0.9384