Anda di halaman 1dari 6

hasil biaya

480
50
425
40
445
55
395
35
405
45
425
40
455
50
475
65
435
45
480
50
505
60
490
55
475
45
460
35
470
50
465
45
495
60
485
55
attach(latihan)#untuk mendeskripsikan variabel yang ada disebuah data, biar R bi
sa ngerti apa yg dimaksud
> setwd("D:")
> dir()
[1] "$RECYCLE.BIN"
[2] "2012_11_02"
[3] "about english"
[4] "afk.docx"
[5] "ANALISIS KELOMPOK JUMLAH KASUS WABAH PENYAKIT DI KABUPATEN.pptx"
[6] "asistensi"
[7] "autokorelasi (1).rar"
[8] "belajar SPSS"
[9] "Book1.xlsx"
[10] "cilacs EGP 1"
[11] "CILACS EGP 2"
[12] "contoh kuisioner"
[13] "coreldrawku"
[14] "dari download"
[15] "download ebook"
[16] "download kedua"
[17] "eaea"
[18] "FileZilla_3.5.3_win32.zip"
[19] "gammurc"
[20] "JUDUL.doc"
[21] "Jurnal"
[22] "kerja praktek"
[23] "KKN"
[24] "Kuliahku"
[25] "listening active english"
[26] "listening cept preparation"
[27] "master"
[28] "Materi buat UAS"
[29] "materi dan isi PKM"
[30] "Minitab"
[31] "organisasi"
[32] "panduan memakai ms office"
[33] "PEMASARAN"
[34] "poling dengan grafik"
[35] "Presentasi SMT.pptx"
[36] "Research in Motion"

[37] "searchplugins"
[38] "System Volume Information"
> setwd("D:")
> dir()
[1] "$RECYCLE.BIN"
[2] "2012_11_02"
[3] "about english"
[4] "afk.docx"
[5] "ANALISIS KELOMPOK JUMLAH KASUS WABAH PENYAKIT DI KABUPATEN.pptx"
[6] "asistensi"
[7] "autokorelasi (1).rar"
[8] "belajar SPSS"
[9] "Book1.xlsx"
[10] "cilacs EGP 1"
[11] "CILACS EGP 2"
[12] "contoh kuisioner"
[13] "coreldrawku"
[14] "dari download"
[15] "data praktikum 4.txt"
[16] "download ebook"
[17] "download kedua"
[18] "eaea"
[19] "FileZilla_3.5.3_win32.zip"
[20] "gammurc"
[21] "JUDUL.doc"
[22] "Jurnal"
[23] "kerja praktek"
[24] "KKN"
[25] "Kuliahku"
[26] "listening active english"
[27] "listening cept preparation"
[28] "master"
[29] "Materi buat UAS"
[30] "materi dan isi PKM"
[31] "Minitab"
[32] "organisasi"
[33] "panduan memakai ms office"
[34] "PEMASARAN"
[35] "poling dengan grafik"
[36] "Presentasi SMT.pptx"
[37] "Research in Motion"
[38] "searchplugins"
[39] "System Volume Information"
> latihan=read.table("data praktikum 4.txt")
> latihan
V1
V2
1 hasil biaya
2
480
50
3
425
40
4
445
55
5
395
35
6
405
45
7
425
40
8
455
50
9
475
65
10 435
45
11 480
50
12 505
60
13 490
55
14 475
45

15 460
35
16 470
50
17 465
45
18 495
60
19 485
55
> fix(latihan)
> latihan=read.table("data praktikum 4.txt",header=T)
> fix(latihan)
> attach(latihan)
> y=hasil
> x=biaya
> model=y~x
> plot(model,data=latihan)
> qq.plot(x)
Error: could not find function "qq.plot"
> library(car)
Loading required package: MASS
Loading required package: nnet
> qq.plot(x)
Warning message:
'qq.plot' is deprecated.
Use 'qqPlot' instead.
See help("Deprecated") and help("car-deprecated").
> qq.plot(latihan$biaya)
Warning message:
'qq.plot' is deprecated.
Use 'qqPlot' instead.
See help("Deprecated") and help("car-deprecated").
> qq.plot(latihan$hasil, col="blue")
Warning message:
'qq.plot' is deprecated.
Use 'qqPlot' instead.
See help("Deprecated") and help("car-deprecated").
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session --Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type)
:
no packages were specified
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
> reg<-lm(y~x, data=latihan)
> reg
Call:
lm(formula = y ~ x, data = latihan)
Coefficients:
(Intercept)
332.410

x
2.593

> abline(reg)
> abline(reg)
> abline()
> abline(reg)
Error in int_abline(a = a, b =
plot.new has not been called
> abline(reg)
Error in int_abline(a = a, b =
plot.new has not been called
> reg<-lm(y~x, data=latihan)

b, h = h, v = v, untf = untf, ...) :


yet
b, h = h, v = v, untf = untf, ...) :
yet

> abline(reg)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
plot.new has not been called yet
> summary(reg)
Call:
lm(formula = y ~ x, data = latihan)
Residuals:
Min
1Q Median
3Q
Max
-44.084 -13.343 7.489 16.748 36.844
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 332.4095
32.5355 10.217 2.04e-08 ***
x
2.5928
0.6562 3.951 0.00114 **
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1

Residual standard error: 22.99 on 16 degrees of freedom


Multiple R-squared: 0.4939,
Adjusted R-squared: 0.4622
F-statistic: 15.61 on 1 and 16 DF, p-value: 0.001144
> anova(reg)
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x
1 8253.6 8253.6 15.612 0.001144 **
Residuals 16 8458.9 528.7
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05
> reg=function(x,y)
+ {
+ n=length(x[,1])
+ xx=matrix(c(rep(1,n),x),nrow=n)
+ betha=solve(t(xx)%*%xx)%*%t(xx)%*%y
+ cat("koefisien regresi:\n")
+ cat("b0:",betha[1,1],"\n")
+ cat("x1:",betha[2,1],"\n")
+ cat("x2:",betha[3,1],"\n")
+ cat("x3:",betha[4,1],"\n")
+ }
> scan()
1: 12
2: 34
3: 35
4: 32
5: 33
6:
Read 5 items
[1] 12 34 35 32 33
>
> x1=scan()
1: 12
2: 33
3: 4
4: 5
5: 21
6:

0.1

Read 5 items
> x2=scan()
1: 12
2: 43
3: 54
4: 78
5: 12
6:
Read 5 items
> x3=scan()
1: 54
2: 90
3: 12
4: 32
5: 12
6:
Read 5 items
> x=matrix(c(x1,x2,x3),nrow=5)
> x
[,1] [,2] [,3]
[1,] 12 12 54
[2,] 33 43 90
[3,]
4 54 12
[4,]
5 78 32
[5,] 21 12 12
> y
[1] 480 425 445 395 405 425 455 475 435 480 505 490 475 460 470 465 495 485
> reg=function(x,y)
+ {
+ n=length(x[,1])
+ xx=matrix(c(rep(1,n),x),nrow=n)
+ betha=solve(t(xx)%*%xx)%*%t(xx)%*%y
+ cat("koefisien regresi:\n")
+ cat("b0:",betha[1,1],"\n")
+ cat("x1:",betha[2,1],"\n")
+ cat("x2:",betha[3,1],"\n")
+ cat("x3:",betha[4,1],"\n")
+ }
> reg(x,y)
Error in solve(t(xx) %*% xx) %*% t(xx) %*% y : non-conformable arguments
> reg(x,y)
Error in solve(t(xx) %*% xx) %*% t(xx) %*% y : non-conformable arguments
> x
[,1] [,2] [,3]
[1,] 12 12 54
[2,] 33 43 90
[3,]
4 54 12
[4,]
5 78 32
[5,] 21 12 12
> rm(y)
> y
Error: object 'y' not found
> y=scan()
1: 21
2: 22
3: 23
4: 23
5: 25
6:
Read 5 items

> y
[1] 21 22 23 23 25
> reg(x,y)
koefisien regresi:
b0: 22.53554
x1: 0.1362114
x2: 0.01981442
x3: -0.06418309
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Versi Rcmdr 1.8-3
Attaching package: 'Rcmdr'
The following object(s) are masked from 'package:tcltk':
tclvalue
> fix(data)
> fix(Dataset)
> lm(y~x2+x3-1,data=Dataset)
Call:
lm(formula = y ~ x2 + x3 - 1, data = Dataset)
Coefficients:
x2
x3
1.04382 0.01037
>