The Simple Linear Regression
use "C:\Users\Windows 10 Gamer.PURWANTO\Desktop\Using Stata\Data POT\food.dta", clear . describe
Contains data from C:\Users\Windows 10 Gamer.PURWANTO\Desktop\Using Stata\Data POT\food.dta
obs: 40 vars: 2 size: 640
--- ---
storage display value
variable name type format label variable label
--- ---
food_exp double %10.0g household food expenditure per week income double %10.0g weekly household income
--- ---
Sorted by:
. summarize
Variable | Obs Mean Std. Dev. Min Max ---+--- food_exp | 40 283.5735 112.6752 109.71 587.66 income | 40 19.60475 6.847773 3.69 33.4
. tabstat food_exp income semua variable, khusus mean stats | food_exp income
---+--- mean | 283.5735 19.60475
. . tabstat food_exp income, stat(n mean sd max min) stats | food_exp income
---+--- N | 40 40 mean | 283.5735 19.60475 sd | 112.6752 6.847773 max | 587.66 33.4 min | 109.71 3.69
. tabstat food_exp income, stat(n mean sd max min) col(stat) variable | N mean sd max min ---+--- food_exp | 40 283.5735 112.6752 587.66 109.71 income | 40 19.60475 6.847773 33.4 3.69 --- . . tabstat food_exp income, stat(n mean var max min) col(stat) variable | N mean variance max min ---+--- food_exp | 40 283.5735 12695.7 587.66 109.71 income | 40 19.60475 46.89199 33.4 3.69 ---
tabstat food_exp income, stat(n mean var skew kurt) col(stat) variable | N mean variance skewness kurtosis ---+--- food_exp | 40 283.5735 12695.7 .4920827 2.851522 income | 40 19.60475 46.89199 -.6265073 3.279728 ---
Korelasi
. correlate food_exp income (obs=40)
| food_exp income ---+--- food_exp | 1.0000
income | 0.6205 1.0000
. correlate food_exp income, mean
selain korelasi, ditampilkan statistic deskriptif
(obs=40)
Variable | Mean Std. Dev. Min Max ---+--- food_exp | 283.5735 112.6752 109.71 587.66 income | 19.60475 6.847773 3.69 33.4
| food_exp income ---+--- food_exp | 1.0000
income | 0.6205 1.0000
. pwcorr food_exp income
| food_exp income ---+--- food_exp | 1.0000
income | 0.6205 1.0000
. pwcorr food_exp income, obs sig
ditampilkan banyak sampeel dan probability
| food_exp income ---+--- food_exp | 1.0000
|
| 40 |
income | 0.6205 1.0000 | 0.0000
| 40 40
Menampilkan grafik
Grafik scatter
. twoway (scatter food_exp income)
10 0 20 0 30 0 40 0 50 0 60 0 ho us eh ol d fo od e xp en di tu re p er w ee k
0 10 20 30 40
weekly household income
Jika scale dari X dan Y diubah
twoway (scatter food_exp income), ylabel(0(100)600) xlabel(0(5)35) title(Food Expenditure Data)
ylabel(0(100)600) untuk Y dimulai dari 0 sampai dengan 600, dengan skala 100 xlabel(0(5)35) untuk X dimulai dari 0 sampai dengan 35, skala 5
title(Food Expenditure Data) judul grafik “title = Food Expenditure Data
0 10 0 20 0 30 0 40 0 50 0 60 0 ho us eh ol d fo od e xp en di tu re p er w ee k
0 5 10 15 20 25 30 35
weekly household income
Food Expenditure Data
. twoway (scatter food_exp income), ylabel(0(100)600) xlabel(0(5)35) title(Food Expenditure Data) xtitle(Pendapatan RT) ytitle(Pengeluaran RT mingguan)
0 10 0 20 0 30 0 40 0 50 0 60 0 P en ge lu ar a n R T m in gg ua n
0 5 10 15 20 25 30 35
Pendapatan RT
Food Expenditure Data
. twoway (scatter food_exp income) (lfit food_exp income), ylabel(0(100)600) xlabel(0(5)35) title(Food Expenditure Data) xtitle(Pendapatan RT)
(lfit food_exp income) menggambarkan fit antara variable
0 10 0 20 0 30 0 40 0 50 0 60 0
0 5 10 15 20 25 30 35
Pendapatan RT
household food expenditure per week Fitted values
Food Expenditure Data
Grafik histogram
. histogram income
(bin=6, start=3.69, width=4.9516667)
0 .0 2 .0 4 .0 6 .0 8 D e ns ity
5 10 15 20 25 30
weekly household income
Dalam percent
histogram income, percent
(bin=6, start=3.69, width=4.9516667)
0 10 20 30 40 P er ce nt
5 10 15 20 25 30
weekly household income
Regresi Linear sederhana
. regress food_exp income
Source | SS df MS Number of obs = 40 ---+--- F(1, 38) = 23.79 Model | 190626.984 1 190626.984 Prob > F = 0.0000 Residual | 304505.176 38 8013.2941 R-squared = 0.3850 ---+--- Adj R-squared = 0.3688 Total | 495132.16 39 12695.6964 Root MSE = 89.517 --- food_exp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- income | 10.20964 2.093264 4.88 0.000 5.972052 14.44723 _cons | 83.416 43.41016 1.92 0.062 -4.463279 171.2953 --- . predict ehat, residuals prediksi residual
. histogram ehat, percent
(bin=6, start=-223.02548, width=72.511584)
0 10 20 30 P er ce nt
-200 -100 0 100 200
Residuals
Pengujian parameter
. lincom income pengujian menggunakan uji t pengujian 1 variabel bebas ( 1) income = 0
--- food_exp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | 10.20964 2.093264 4.88 0.000 5.972052 14.44723 ---
Pengujian menggunakan uji t
. lincom income – 10
pengujian income = 10
( 1) income = 10
--- food_exp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | .209643 2.093264 0.10 0.921 -4.027948 4.447233 --- Pengujian apakah suppins = 0.5
. lincom suppins - 0.5 ( 1) suppins = .5
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | -.2246371 .0455897 -4.93 0.000 -.314028 -.1352461 --- Pengujian suppins = -0.5
. lincom suppins + 0.5 ( 1) suppins = -.5
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | .7753629 .0455897 17.01 0.000 .685972 .8647539 ---
Pengujian apakah variable suppins = totchr
penngujian melibatkan 2 variabel
. lincom suppins - totchr ( 1) suppins - totchr = 0
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | -.0988464 .0497555 -1.99 0.047 -.1964053 -.0012874
Pengujian apakah variable suppins = 2*totchr dan merubah conf. interval 90%
. lincom suppins -2*totchr, level(90)
level () dipakai untuk merubah confidence interval
( 1) suppins - 2*totchr = 0
--- ltotexp | Coef. Std. Err. t P>|t| [90% Conf. Interval]
---+--- (1) | -.4730557 .0595983 -7.94 0.000 -.571117 -.3749943 ---
Pengujian menggunakan uji F
test suppins ( 1) suppins = 0
F( 1, 2948) = 36.48 Prob > F = 0.0000 Bandingkan dengan sebelumnya : . lincom suppins
( 1) suppins = 0
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | .2753629 .0455897 6.04 0.000 .185972 .3647539 --- t = 6.04, t2 =(6.04) = 36.48 uji F
Selain itu, tidak ditampilkan confidence interval
Pengujian apakah suppins = 0.5
. test suppins = 0.5 terdapat perbedaan argument saat menggunkan lincom ( 1) suppins = .5
F( 1, 2948) = 24.28 Prob > F = 0.0000 Bandingkan dengan sebelumnya . lincom suppins - 0.5 ( 1) suppins = .5
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | -.2246371 .0455897 -4.93 0.000 -.314028 -.1352461 --- t = -4.93 t2 = (-4.93)2 = 24.30 same as test F
Pengujian apakah variable suppins = totchr . test suppins = totchr
( 1) suppins - totchr = 0 F( 1, 2948) = 3.95 Prob > F = 0.0471 Sebelumnya
. lincom suppins - totchr ( 1) suppins - totchr = 0
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | -.0988464 .0497555 -1.99 0.047 -.1964053 -.0012874 Pengujian lebih dari 2 variabel
. lincom suppins - totchr + age ( 1) suppins - totchr + age = 0
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | -.0959317 .0502366 -1.91 0.056 -.1944341 .0025706 --- . test suppins = totchr - age
( 1) suppins - totchr + age = 0 F( 1, 2948) = 3.65 Prob > F = 0.0563 .
.
. . test suppins + age = totchr ( 1) suppins - totchr + age = 0 F( 1, 2948) = 3.65 Prob > F = 0.0563
. . lincom suppins - totchr + age -2 ( 1) suppins - totchr + age = 2
--- ltotexp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- (1) | -2.095932 .0502366 -41.72 0.000 -2.194434 -1.997429 --- . test suppins - totchr + age = 2
( 1) suppins - totchr + age = 2 F( 1, 2948) = 1740.66 Prob > F = 0.0000 Pengujian bersama
. test suppins totchr age ( 1) suppins = 0
( 2) totchr = 0 ( 3) age = 0
F( 3, 2948) = 152.61 Prob > F = 0.0000
Pengujian ini, tidak bisa menggunakan lincom
Title
[R] lincom -- Linear combinations of parameters
Syntax
lincom exp [, options]
options Description
--- eform generic label; exp(b)
or odds ratio hr hazard ratio shr subhazard ratio irr incidence-rate ratio rrr relative-risk ratio
level(#) set confidence level; default is level(95) display_options control column formats
df(#) use t distribution with # degrees of freedom for computing p- values and confidence intervals
--- exp is any linear combination of coefficients that is valid syntax for test; see [R] test. exp must not contain an equal sign.
df(#) does not appear in the dialog box.
Menu
Statistics > Postestimation
Description
lincom computes point estimates, standard errors, t or z statistics, p-values, and confidence intervals for linear combinations of coefficients after any estimation command, including
survey estimation. Results can optionally be displayed as odds ratios, hazard ratios, incidence-rate ratios, or relative-risk ratios.
Options
eform, or, hr, shr, irr, and rrr all report coefficient estimates as exp(b) rather than b. Standard errors and confidence intervals are similarly transformed. or is the default
after logistic. The only difference in these options is how the output is labeled.
Option Label Explanation Example commands --- eform exp(b) Generic label cloglog
or Odds Ratio Odds ratio logistic, logit hr Haz. Ratio Hazard ratio stcox, streg shr SHR Subhazard ratio stcrreg irr IRR Incidence-rate ratio poisson rrr RRR Relative-rate ratio mlogit
---
exp may not contain any additive constants when you use the eform, or, hr, irr, or rrr option.
level(#) specifies the confidence level, as a percentage, for confidence intervals. The default is level(95) or as set by set level.
display_options: cformat(%fmt), pformat(%fmt), and sformat(%fmt); see [R]
estimation options.
The following option is available with lincom but is not shown in the dialog box:
df(#) specifies that the t distribution with # degrees of freedom be used for computing p-values and confidence intervals. The default is to use e(df_r) degrees of freedom or the
standard normal distribution if e(df_r) is missing.
Examples Setup
. webuse regress . regress y x1 x2 x3
Estimate linear combinations of coefficients . lincom x2-x1
. lincom 3*x1 + 500*x3 . lincom 3*x1 + 500*x3 - 12
--- Setup
. webuse lbw
Fit logistic regression, reporting coefficients . logit low age lwt i.race smoke ptl ht ui
Estimate linear combination of coefficients; report odds ratio . lincom 2.race+smoke, or
Fit logistic regression, reporting odds ratios . logistic low age lwt i.race smoke ptl ht ui lincom after logistic reports odds ratios by default . lincom 2.race+smoke
--- Setup
. webuse sysdsn1
. mlogit insure age male nonwhite i.site
Estimate linear combination of coefficients from Prepaid equation . lincom [Prepaid]male + [Prepaid]nonwhite
Kembali menggunakan Carter, mulai ch 5
. use "C:\Users\Windows 10 Gamer.PURWANTO\Desktop\Using Stata\Data POT\andy.dta", clear
. summarize
Variable | Obs Mean Std. Dev. Min Max ---+--- sales | 75 77.37467 6.488537 62.4 91.2 price | 75 5.6872 .518432 4.83 6.49 advert | 75 1.844 .8316769 .5 3.1
describe
Contains data from C:\Users\Windows 10 Gamer.PURWANTO\Desktop\Using Stata\Data POT\andy.dta
obs: 75 vars: 3 size: 1,800
--- storage display value
variable name type format label variable label
--- sales double %10.0g Monthly sales revenue ($1000s)
price double %10.0g A price index for all products sold in a given month.
advert double %10.0g Expenditure on advertising ($1000s) --- Sorted by:
Regresi
. regress sales price advert
Source | SS df MS Number of obs = 75 ---+--- F(2, 72) = 29.25 Model | 1396.53893 2 698.269465 Prob > F = 0.0000 Residual | 1718.94294 72 23.8742075 R-squared = 0.4483 ---+--- Adj R-squared = 0.4329 Total | 3115.48187 74 42.1011063 Root MSE = 4.8861 --- sales | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- price | -7.907854 1.095993 -7.22 0.000 -10.09268 -5.723032 advert | 1.862584 .6831955 2.73 0.008 .500659 3.22451 _cons | 118.9136 6.351638 18.72 0.000 106.2519 131.5754 ---
Confidence interval 99%
. regress sales price advert, level(99) dinyatakan dalam 99
Source | SS df MS Number of obs = 75 ---+--- F(2, 72) = 29.25 Model | 1396.53893 2 698.269465 Prob > F = 0.0000 Residual | 1718.94294 72 23.8742075 R-squared = 0.4483 ---+--- Adj R-squared = 0.4329 Total | 3115.48187 74 42.1011063 Root MSE = 4.8861 --- sales | Coef. Std. Err. t P>|t| [99% Conf. Interval]
---+--- price | -7.907854 1.095993 -7.22 0.000 -10.80769 -5.008019 advert | 1.862584 .6831955 2.73 0.008 .0549502 3.670218 _cons | 118.9136 6.351638 18.72 0.000 102.1081 135.7191 --- . regress sales price advert, level(99) noconstant konstanta dihilangkan Source | SS df MS Number of obs = 75 ---+--- F(2, 73) = 1599.55 Model | 442041.486 2 221020.743 Prob > F = 0.0000 Residual | 10086.9239 73 138.17704 R-squared = 0.9777 ---+--- Adj R-squared = 0.9771 Total | 452128.41 75 6028.3788 Root MSE = 11.755 --- sales | Coef. Std. Err. t P>|t| [99% Conf. Interval]
---+--- price | 12.12089 .5728601 21.16 0.000 10.60575 13.63603 advert | 4.068586 1.618979 2.51 0.014 -.2134001 8.350572 --- . regress sales price advert
Source | SS df MS Number of obs = 75 ---+--- F(2, 72) = 29.25 Model | 1396.53893 2 698.269465 Prob > F = 0.0000 Residual | 1718.94294 72 23.8742075 R-squared = 0.4483 ---+--- Adj R-squared = 0.4329 Total | 3115.48187 74 42.1011063 Root MSE = 4.8861 --- sales | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- price | -7.907854 1.095993 -7.22 0.000 -10.09268 -5.723032 advert | 1.862584 .6831955 2.73 0.008 .500659 3.22451 _cons | 118.9136 6.351638 18.72 0.000 106.2519 131.5754 --- . estat vce
Covariance matrix of coefficients of regress model e(V) | price advert _cons ---+--- price | 1.2012007 advert | -.01974215 .46675606 _cons | -6.7950641 -.7484206 40.343299
Var(b1) = 1.2012007
sb1 = 1.09599302 sb1 price
Var(b2) = .46675606 sb2 = 0.683195477 sb advert Var(b3) = 40.343299 sb3 = 6.351637505 sb constanta
Menggunakan variable dummy
. use "C:\Users\Windows 10 Gamer.PURWANTO\Desktop\Using Stata\mus\mus03data.dta", clear
. summ
Variable | Obs Mean Std. Dev. Min Max ---+--- dupersid | 3,064 6.24e+07 3.43e+07 2.00e+07 9.83e+07
year03 | 3,064 1 0 1 1
age | 3,064 74.17167 6.372938 65 90
famsze | 3,064 1.907963 .9883496 1 13
educyr | 3,064 11.77546 3.435878 0 17
---+--- totexp | 3,064 7030.889 11852.75 0 125610
private | 3,064 .5812663 .4934321 0 1
retire | 3,064 .5946475 .4910403 0 1
female | 3,064 .5796345 .4936982 0 1
white | 3,064 .9742167 .1585141 0 1
---+--- hisp | 3,064 .0848564 .2787134 0 1
marry | 3,064 .5558094 .4969567 0 1
northe | 3,064 .1517624 .358849 0 1
mwest | 3,064 .2310705 .4215862 0 1
south | 3,064 .3962141 .4891897 0 1
---+--- phylim | 3,064 .4255875 .4945125 0 1
actlim | 3,064 .2836162 .4508263 0 1
msa | 3,064 .7415144 .4378737 0 1
income | 3,064 22.47472 22.53491 -1 312.46 injury | 3,064 .1964752 .3973968 0 1
---+--- priolist | 3,064 .8028721 .3978947 0 1
totchr | 3,064 1.754243 1.307197 0 7
omc | 3,064 .4461488 .4971727 0 1
hmo | 3,064 .1158616 .3201111 0 1
mnc | 3,064 .0192559 .1374454 0 1
---+--- ratio | 3,064 .0120952 .0958159 0 1
posexp | 3,064 .9644256 .1852568 0 1
suppins | 3,064 .5812663 .4934321 0 1
hvgg | 3,064 .6054178 .4888406 0 1
hfp | 3,064 .2078982 .4216508 0 2
---+--- ltotexp | 2,955 8.059866 1.367592 1.098612 11.74094 hins | 1,506 1 0 1 1
hdem | 1,737 1 0 1 1
. regress dupersid age famsze totexp retire female Source | SS df MS Number of obs = 3,064 ---+--- F(5, 3058) = 1.15 Model | 6.7603e+15 5 1.3521e+15 Prob > F = 0.3329 Residual | 3.6031e+18 3,058 1.1783e+15 R-squared = 0.0019 ---+--- Adj R-squared = 0.0002 Total | 3.6099e+18 3,063 1.1786e+15 Root MSE = 3.4e+07 --- dupersid | Coef. Std. Err. t P>|t| [95% Conf. Interval] ---+--- age | 39025.09 99033.1 0.39 0.694 -155153.1 233203.3 famsze | 679284.8 644606.1 1.05 0.292 -584620.2 1943190
totexp | 11.62878 52.43965 0.22 0.825 -91.19174 114.4493 retire | -2682542 1332020 -2.01 0.044 -5294287 -70796.6 female | -413713.4 1333963 -0.31 0.756 -3029268 2201841 _cons | 6.00e+07 7699985 7.79 0.000 4.49e+07 7.51e+07 ---
Age, famsze, totexp variable continuous disingkat c Retire, female variable dummy atau discret disingkat i Maka interaksi antara Age dengan famsze menjadi c.age#c.famsze Interaksi antara Age dengan retire c.age#i.retire
Interaksi antara tetire dengan female i.retire#i.female
. regress dupersid age famsze totexp retire female c.famsze#c.age
Source | SS df MS Number of obs = 3,064 ---+--- F(6, 3057) = 1.25 Model | 8.8295e+15 6 1.4716e+15 Prob > F = 0.2778 Residual | 3.6011e+18 3,057 1.1780e+15 R-squared = 0.0024 ---+--- Adj R-squared = 0.0005 Total | 3.6099e+18 3,063 1.1786e+15 Root MSE = 3.4e+07 --- dupersid | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- age | -198092.8 204484.3 -0.97 0.333 -599033.5 202847.9 famsze | -8948212 7292660 -1.23 0.220 -2.32e+07 5350800 totexp | 12.46506 52.43696 0.24 0.812 -90.35021 115.2803 retire | -2672632 1331876 -2.01 0.045 -5284095 -61167.86 female | -299693.2 1336569 -0.22 0.823 -2920359 2320972 |
c.famsze#c.age | 131609.4 99301.72 1.33 0.185 -63095.45 326314.3 |
_cons | 7.74e+07 1.52e+07 5.09 0.000 4.75e+07 1.07e+08 --- . regress dupersid age famsze totexp retire female c.famsze#i.female i.female#i.retire note: 1.female#0b.retire omitted because of collinearity
note: 1.female#1.retire omitted because of collinearity
Source | SS df MS Number of obs = 3,064 ---+--- F(7, 3056) = 0.98 Model | 8.0577e+15 7 1.1511e+15 Prob > F = 0.4463 Residual | 3.6018e+18 3,056 1.1786e+15 R-squared = 0.0022 ---+--- Adj R-squared = -0.0001 Total | 3.6099e+18 3,063 1.1786e+15 Root MSE = 3.4e+07 --- dupersid | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- age | 40577.15 99327.14 0.41 0.683 -154177.6 235331.9 famsze | -40809.15 1025402 -0.04 0.968 -2051356 1969738 totexp | 10.62807 52.4586 0.20 0.839 -92.22963 113.4858 retire | -3094810 1649019 -1.88 0.061 -6328108 138487.3 female | -1783345 3555078 -0.50 0.616 -8753930 5187241 |
female#c.famsze |
1 | 1157836 1309372 0.88 0.377 -1409502 3725174 |
female#retire |
0 1 | 1335085 2800940 0.48 0.634 -4156831 6827002 1 0 | 0 (omitted)
1 1 | 0 (omitted) |
_cons | 6.06e+07 7875101 7.70 0.000 4.52e+07 7.61e+07 --- . regress dupersid age famsze totexp c.famsze#i.female i.female#i.retire
Source | SS df MS Number of obs = 3,064 ---+--- F(7, 3056) = 0.98 Model | 8.0577e+15 7 1.1511e+15 Prob > F = 0.4463 Residual | 3.6018e+18 3,056 1.1786e+15 R-squared = 0.0022 ---+--- Adj R-squared = -0.0001 Total | 3.6099e+18 3,063 1.1786e+15 Root MSE = 3.4e+07
--- dupersid | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- age | 40577.15 99327.14 0.41 0.683 -154177.6 235331.9 famsze | -40809.15 1025402 -0.04 0.968 -2051356 1969738 totexp | 10.62807 52.4586 0.20 0.839 -92.22963 113.4858 |
female#c.famsze |
1 | 1157836 1309372 0.88 0.377 -1409502 3725174 |
female#retire |
0 1 | -1759725 2264677 -0.78 0.437 -6200170 2680719 1 0 | -1783345 3555078 -0.50 0.616 -8753930 5187241 1 1 | -4878155 3478195 -1.40 0.161 -1.17e+07 1941684 |
_cons | 6.06e+07 7875101 7.70 0.000 4.52e+07 7.61e+07 . regress dupersid age famsze totexp c.famsze#i.female i.female##i.retire
Source | SS df MS Number of obs = 3,064 ---+--- F(7, 3056) = 0.98 Model | 8.0577e+15 7 1.1511e+15 Prob > F = 0.4463 Residual | 3.6018e+18 3,056 1.1786e+15 R-squared = 0.0022 ---+--- Adj R-squared = -0.0001 Total | 3.6099e+18 3,063 1.1786e+15 Root MSE = 3.4e+07 --- dupersid | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- age | 40577.15 99327.14 0.41 0.683 -154177.6 235331.9 famsze | -40809.15 1025402 -0.04 0.968 -2051356 1969738 totexp | 10.62807 52.4586 0.20 0.839 -92.22963 113.4858 |
female#c.famsze |
1 | 1157836 1309372 0.88 0.377 -1409502 3725174 |
1.female | -1783345 3555078 -0.50 0.616 -8753930 5187241 1.retire | -1759725 2264677 -0.78 0.437 -6200170 2680719 |
female#retire |
1 1 | -1335085 2800940 -0.48 0.634 -6827002 4156831 |
_cons | 6.06e+07 7875101 7.70 0.000 4.52e+07 7.61e+07 --- Regresi dengan constraint
. use "C:\Users\Windows 10 Gamer.PURWANTO\Desktop\Using Stata\Data POT\beer.dta", clear
. summarize
Variable | Obs Mean Std. Dev. Min Max ---+--- q | 30 56.11333 7.857381 44.3 81.7 pb | 30 3.08 .6421945 1.78 4.07 pl | 30 8.367333 .7696346 6.95 9.52 pr | 30 1.251333 .298314 .67 1.73 i | 30 32601.8 4541.966 25088 41593 misalkan variable q, pb, pl,pr dan I ditransformasikan kedalam ln generate lq = ln(q)
. generate lpb =ln(pb) . generate lpl =ln(pl) . generate lpr =ln(pr) . generate li =ln(i)
. constraint 1 lpb+lpl+lpr+li=0 tentukan terlebih dahulu constrainnya . cnsreg lq lpb lpl lpr li, c(1)
Constrained linear regression Number of obs = 30 F( 3, 26) = 36.46 Prob > F = 0.0000 Root MSE = 0.0617 ( 1) lpb + lpl + lpr + li = 0
--- lq | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- lpb | -1.299387 .1657377 -7.84 0.000 -1.640065 -.958708 lpl | .1868161 .2843833 0.66 0.517 -.3977422 .7713744 lpr | .1667424 .0770752 2.16 0.040 .0083121 .3251727 li | .9458282 .4270468 2.21 0.036 .0680209 1.823635 _cons | -4.797793 3.713905 -1.29 0.208 -12.43183 2.836247 --- . constraint 1 lpb+lpl+lpr+li=1
.
. cnsreg lq lpb lpl lpr li, c(1)
Constrained linear regression Number of obs = 30 Root MSE = 0.0826 ( 1) lpb + lpl + lpr + li = 1
--- lq | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- lpb | -1.891746 .2220561 -8.52 0.000 -2.348189 -1.435303 lpl | 1.821299 .381018 4.78 0.000 1.038105 2.604493 lpr | .0758549 .1032656 0.73 0.469 -.1364106 .2881205 li | .9945918 .5721591 1.74 0.094 -.1814981 2.170682 _cons | -8.098741 4.975905 -1.63 0.116 -18.32686 2.129378 --- ... constraint 1 lpb+lpl+lpr+li=1
.
. cnsreg lq lpb lpl lpr li, c(1) noconstant
Constrained linear regression Number of obs = 30 Root MSE = 0.0851 ( 1) lpb + lpl + lpr + li = 1
--- lq | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- lpb | -1.604721 .1390037 -11.54 0.000 -1.889933 -1.319509 lpl | 2.40453 .1333841 18.03 0.000 2.130848 2.678211 lpr | .1363253 .0992493 1.37 0.181 -.0673174 .339968
li | .0638659 .0196059 3.26 0.003 .0236379 .1040938 ---
Pendugaan indicator variable