Lampiran R Studio

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

LAMPIRAN R STUDIO

R version 4.1.1 (2021-08-10) -- "Kick Things"


Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.


You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
DESKRIPSI
R SCRPT
1. dim(penelitian)
2. head (penelitian)
3. str (penelitian)
4. summary(penelitian)
5. #Standar Deviasi
6. sd (penelitian$Y)
7. sd (penelitian$`Perbandingan Laki2`)
8. sd (penelitian$`Total Komorbid`)
9. sd (penelitian$`Kepadatan Penduduk`)
10. sd (penelitian$`Kontak Erat`)
11. sd (penelitian$`Persentase Lansia`)
12. Hmisc::describe(penelitian$Y)
13. Hmisc::describe(penelitian$`Total Komorbid`)
14. Hmisc::describe(penelitian$`Kepadatan Penduduk`)
15. Hmisc::describe(penelitian$`Kontak Erat`)
16. Hmisc::describe(penelitian$`Persentase Lansia`)
17. library(moments)
18. #Histogram
19. hist(penelitian$Y)
20. hist(penelitian$`Perbandingan Laki2`)
21. hist(penelitian$`Total Komorbid`)
22. hist(penelitian$`Kepadatan Penduduk`)
23. hist(penelitian$`Kontak Erat`)
24. hist(penelitian$`Persentase Lansia`)
> getwd ()
[1] "E:/deskripsi"
> library (readxl)
> penelitian <- read_excel("cgto.xls")
> View(penelitian)
> View(penelitian)
> save.image("E:/deskripsi/zzz.RData")
> dim(penelitian)
[1] 19 6
> head (penelitian)
# A tibble: 6 x 6
Y `Perbandingan Laki2` `Total Komorbid` `Kepadatan Penduduk` `Kontak Erat`
<dbl> <dbl> <dbl> <dbl> <dbl>
1 395 0.990 1546 482 235
2 86 0.991 870 318 67
3 209 1.01 859 276 164
4 130 1.00 930 825 78
5 77 1.03 632 2823 49
6 65 0.994 598 1970 53
# ... with 1 more variable: Persentase Lansia <dbl>
> str (penelitian)
tibble [19 x 6] (S3: tbl_df/tbl/data.frame)
$Y : num [1:19] 395 86 209 130 77 65 17 63 35 20 ...
$ Perbandingan Laki2: num [1:19] 0.99 0.991 1.006 1.004 1.029 ...
$ Total Komorbid : num [1:19] 1546 870 859 930 632 ...
$ Kepadatan Penduduk: num [1:19] 482 318 276 825 2823 ...
$ Kontak Erat : num [1:19] 235 67 164 78 49 53 13 52 28 14 ...
$ Persentase Lansia : num [1:19] 0.0869 0.1024 0.0861 0.0893 0.0787 ...

> summary(penelitian)
Y Perbandingan Laki2 Total Komorbid Kepadatan Penduduk
Min. : 4.00 Min. :0.9899 Min. : 213.0 Min. : 30.0
1st Qu.: 17.00 1st Qu.:1.0028 1st Qu.: 397.0 1st Qu.: 118.0
Median : 43.00 Median :1.0263 Median : 598.0 Median : 278.0
Mean : 70.21 Mean :1.0237 Mean : 696.6 Mean : 487.1
3rd Qu.: 71.00 3rd Qu.:1.0372 3rd Qu.: 864.5 3rd Qu.: 401.0
Max. :395.00 Max. :1.0756 Max. :1890.0 Max. :2823.0

Kontak Erat Persentase Lansia


Min. : 4.00 Min. :0.07492
1st Qu.: 12.50 1st Qu.:0.08518
Median : 29.00 Median :0.09296
Mean : 48.79 Mean :0.09084
3rd Qu.: 52.50 3rd Qu.:0.09583
Max. :235.00 Max. :0.10572
Standar Deviasi
> sd (penelitian$Y)
[1] 93.04394
> sd (penelitian$`Perbandingan Laki2`)
[1] 0.02574988
> sd (penelitian$`Total Komorbid`)
[1] 425.0072
> sd (penelitian$`Kepadatan Penduduk`)
[1] 712.2873
> sd (penelitian$`Kontak Erat`)
[1] 58.57434
> sd (penelitian$`Persentase Lansia`)
[1] 0.00842204

Frekuensi Data
> Hmisc::describe(penelitian$Y)
penelitian$Y
n missing distinct Info Mean Gmd .05 .10 .25
19 0 18 0.999 70.21 82.56 11.2 12.8 17.0
.50 .75 .90 .95
43.0 71.0 145.8 227.6

lowest : 4 12 13 14 17, highest: 77 86 130 209 395

Value 4 12 13 14 17 20 24 35 43 46 63 64
Frequency 1 1 1 1 2 1 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.105 0.053 0.053 0.053 0.053 0.053 0.053 0.053

Value 65 77 86 130 209 395


Frequency 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.053
> Hmisc::describe(penelitian$`Total Komorbid`)
penelitian$`Total Komorbid`
n missing distinct Info Mean Gmd .05 .10 .25
19 0 19 1 696.6 444.6 311.1 345.2 397.0
.50 .75 .90 .95
598.0 864.5 1053.2 1580.4

lowest : 213 322 351 365 378, highest: 870 887 930 1546 1890

Value 213 322 351 365 378 416 443 482 524 598 632 689
Frequency 1 1 1 1 1 1 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053

Value 840 859 870 887 930 1546 1890


Frequency 1 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.053 0.053
> Hmisc::describe(penelitian$`Kepadatan Penduduk`)
penelitian$`Kepadatan Penduduk`
n missing distinct Info Mean Gmd .05 .10 .25
19 0 18 0.999 487.1 597.5 81.3 89.4 118.0
.50 .75 .90 .95
278.0 401.0 1054.0 2055.3

lowest : 30 87 90 103 104, highest: 436 482 825 1970 2823

Value 30 87 90 103 104 132 188 276 278 281 318 334
Frequency 1 1 1 1 1 2 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.105 0.053 0.053 0.053 0.053 0.053 0.053

Value 366 436 482 825 1970 2823


Frequency 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.053
> Hmisc::describe(penelitian$`Kontak Erat`)
penelitian$`Kontak Erat`
n missing distinct Info Mean Gmd .05 .10 .25
19 0 19 1 48.79 54.96 6.7 7.8 12.5
.50 .75 .90 .95
29.0 52.5 95.2 171.1

lowest : 4 7 8 10 12, highest: 53 67 78 164 235

Value 4 7 8 10 12 13 14 19 28 29 38 47
Frequency 1 1 1 1 1 1 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053 0.053

Value 49 52 53 67 78 164 235


Frequency 1 1 1 1 1 1 1
Proportion 0.053 0.053 0.053 0.053 0.053 0.053 0.053
> Hmisc::describe(penelitian$`Persentase Lansia`)
penelitian$`Persentase Lansia`
n missing distinct Info Mean Gmd .05 .10 .25
19 0 19 1 0.09084 0.009797 0.07814 0.07865 0.08518
.50 .75 .90 .95
0.09296 0.09583 0.10091 0.10274

lowest : 0.07491787 0.07849645 0.07868304 0.08302251 0.08425875


highest: 0.09615754 0.09636172 0.10054175 0.10240547 0.10572489

Histogram
hist(penelitian$Y)

hist(penelitian$`Perbandingan Laki2`)

hist(penelitian$`Total Komorbid`)
hist(penelitian$`Kepadatan Penduduk`)

> hist(penelitian$`Kontak Erat`)


> hist(penelitian$`Persentase Lansia`)
Lampiran 3
Output R. Uji Pemodelan Regresi Poisson

> library(readxl)
> View(covidgto)
> View(covidgto)
> covidgto=data.frame(covidgto)
> y=covidgto$Y
> x1=covidgto$x1
> regresi=lm (y~x1)
> regresi

Call:
lm(formula = y ~ x1)

Coefficients:
(Intercept) x1
2174 -2055

> summary(regresi)

Call:
lm(formula = y ~ x1)

Residuals:
Min 1Q Median 3Q Max
-77.51 -50.40 -19.55 17.89 255.36

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2174.4 738.1 2.946 0.00903 **
x1 -2055.5 720.8 -2.852 0.01103 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 78.74 on 17 degrees of freedom


Multiple R-squared: 0.3236, Adjusted R-squared: 0.2838
F-statistic: 8.133 on 1 and 17 DF, p-value: 0.01103
> x2=covidgto$x2
> x3=covidgto$x3
> x4=covidgto$x4
> x5=covidgto$x5
> regresi2=lm (y~x2)
> regresi2

Call:
lm(formula = y ~ x2)
Coefficients:
(Intercept) x2
278.2 -2289.2

> summary (regresi2)

Call:
lm(formula = y ~ x2)

Residuals:
Min 1Q Median 3Q Max
-93.654 -41.875 -33.462 2.043 315.847

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 278.2 239.1 1.163 0.261
x2 -2289.2 2621.3 -0.873 0.395

Residual standard error: 93.66 on 17 degrees of freedom


Multiple R-squared: 0.04294, Adjusted R-squared: -0.01336
F-statistic: 0.7626 on 1 and 17 DF, p-value: 0.3947
> regresi3=lm (y~x3)
> regresi3

Call:
lm(formula = y ~ x3)

Coefficients:
(Intercept) x3
61.03539 0.01884

> summary (regresi3)

Call:
lm(formula = y ~ x3)

Residuals:
Min 1Q Median 3Q Max
-58.99 -47.75 -33.14 -4.29 324.89

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.03539 26.56344 2.298 0.0345 *
x3 0.01884 0.03135 0.601 0.5559
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 94.74 on 17 degrees of freedom
Multiple R-squared: 0.02079, Adjusted R-squared: -0.03681
F-statistic: 0.361 on 1 and 17 DF, p-value: 0.5559
> regresi4=lm (y~x4)
> regresi4

Call:
lm(formula = y ~ x4)

Coefficients:
(Intercept) x4
-22.8267 0.1336
> summary (regresi4)

Call:
lm(formula = y ~ x4)

Residuals:
Min 1Q Median 3Q Max
-165.607 -19.429 -7.373 11.685 211.338

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -22.82669 34.08323 -0.670 0.51202
x4 0.13356 0.04207 3.175 0.00554 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 75.86 on 17 degrees of freedom


Multiple R-squared: 0.3722, Adjusted R-squared: 0.3353
F-statistic: 10.08 on 1 and 17 DF, p-value: 0.00554
> regresi5=lm (y~x5)
> regresi5

Call:
lm(formula = y ~ x5)

Coefficients:
(Intercept) x5
-6.342 1.569

> summary(regresi5)

Call:
lm(formula = y ~ x5)

Residuals:
Min 1Q Median 3Q Max
-41.979 -5.342 3.840 5.220 32.620

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -6.3416 4.5097 -1.406 0.178
x5 1.5690 0.0601 26.108 3.7e-15 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 14.94 on 17 degrees of freedom
Multiple R-squared: 0.9757, Adjusted R-squared: 0.9742
F-statistic: 681.6 on 1 and 17 DF, p-value: 0,03698
Regresi (Simultan)

> x=covidgto$x1+covidgto$x2+covidgto$x3+covidgto$x4+covidgto$x5
> regresi=lm (y~x)
> regresi

Call:
lm(formula = y ~ x)

Coefficients:
(Intercept) x
7.1803 0.0511

> summary(regresi)

Call:
lm(formula = y ~ x)

Residuals:
Min 1Q Median 3Q Max
-109.274 -30.781 -16.961 5.552 272.137

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.18027 33.92827 0.212 0.8349
x 0.05110 0.02264 2.257 0.0375 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 83.98 on 17 degrees of freedom


Multiple R-squared: 0.2306, Adjusted R-squared: 0.1853
F-statistic: 5.094 on 1 and 17 DF, p-value: 0.03746
Durbin-Watson test

data: regresi
DW = 1.0155, p-value = 0.00635
alternative hypothesis: true autocorrelation is greater than 0

bptest(regresi, studentize = FALSE)

Breusch-Pagan test

data: regresi
BP = 11.873, df = 1, p-value = 0.0005694

Call:
lm(formula = y ~ x1 + x2 + x3 + x4 + x5)

Coefficients:
(Intercept) x1 x2 x3 x4 x5
-2.919e+02 2.628e+02 8.059e+01 2.795e-03 9.549e-03 1.595e+00

> summary (NegBinBetaBinreg)

Call:
lm(formula = y ~ x1 + x2 + x3 + x4 + x5)

Residuals:
Min 1Q Median 3Q Max
-40.871 -6.663 0.151 6.260 28.930

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.919e+02 2.545e+02 -1.147 0.272
x1 2.628e+02 2.195e+02 1.197 0.253
x2 8.059e+01 5.576e+02 0.145 0.887
x3 2.795e-03 6.673e-03 0.419 0.682
x4 9.549e-03 1.200e-02 0.796 0.441
x5 1.595e+00 9.252e-02 17.236 2.46e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 16.07 on 13 degrees of freedom


Multiple R-squared: 0.9785, Adjusted R-squared: 0.9702
F-statistic: 118.1 on 5 and 13 DF, p-value: 2.313e-10

You might also like