BookmarkSubscribeRSS Feed
kudamakoni100
Calcite | Level 5

My name is Kuda Makoni from the University of Malawi and i wanted to ask a basic stata question 

 

This is a pretty basic question but i am trying to do a simulation.
 
I have the following equation 
 
y=3.4+0.58b_1 +0.89b_2 
 
so i am trying to see how much y would change if I increased b_1 to 0.9 while b_2 stayed the same.
 
How do i write a simulation code for that?
 
Kuda 
8 REPLIES 8
Reeza
Super User
Determine the range of values for b_1/2.
Simulate those values and then run both models to compare.
kudamakoni100
Calcite | Level 5

How do i do that basically what i am trying to do is 

 

simulation but i am not sure how to do the code. I have a linear equation

y=c+0.05X1+1.28X2

so here i am trying to obtain the values of y and b2 when I fix b1 first at 2 then 0

How do i do that?

PGStats
Opal | Level 21

So you have a function

 

y(b_1, b_2) = 3.4 + 0.58b_1 + 0.89b_2,

 

define a new function as

 

dy(b_1, b_2) = y(b_1, b_2 + 0.9) - y(b_1, b_2)

 

choose a range for b_1 and b_2, and a resolution db for your simulation

 

Calculate the values of dy

 

data simul;
low_b_1 = 0;
high_b_1 = 3;
low_b_2 = -2;
high_b_2 = 2;
db = 0.1;
do b_1 = low_b_1 to high_b_1 by db;
	do b_2 = low_b_2 to high_b_2 by 1;
		dy = 3.4 + 0.58*b_1 + 0.89*(b_2+0.9) - (3.4 + 0.58*b_1 + 0.89*b_2);
		output;
		end;
	end;
keep b_1 b_2 dy;
run;

 

Plot the results with proc sgplot or sgpanel.

 

proc sgplot data=simul;
series y=dy x=b_1 / group=b_2;
run;

proc sgpanel data=simul;
panelby b_2;
series y=dy x=b_1;
run;

 

Of course, the results will not look very interesting unless dy is not a constant function... but you get the idea.

PG
kudamakoni100
Calcite | Level 5

I am so confused right now i am just  trying to do a simulation but i am not sure how to do the code. I have a linear equation

y=c+0.05X1+1.28X2

so here i am trying to obtain the values of y and b2 when I fix b1 first at 2 then 0

How do i do that?

Ksharp
Super User

It is totally depended on the coefficient of b_1 ( 0.58 ), since you don't care about other covariables.

 

 

y=3.4+0.58b_1 +0.89b_2

==>

y-3.4-0.89b_2=0.58b_1

 

So,

y1-3.4-0.89b_2=0.58(b_1+0.9)

-

y0-3.4-0.89b_2=0.58b_1

 

=> y1-y0=0.58*0.9

kudamakoni100
Calcite | Level 5

I am a bit confused the only thing i am trying to do is a simulation but i am not sure how to do the code. I have a linear equation

y=c+0.05X1+1.28X2

so here i am trying to obtain the values of y and b2 when I fix b1 first at 2 then 0

How do i do that?

Reeza
Super User
How is simulation coming into play then? Its a mathematical formula. Or are you trying to run multiple regression models. I don't know if we're interpreting your question correctly.
kudamakoni100
Calcite | Level 5

I am trying to run a multiple regression analysis where i set beta 1 to a certain value then see what happens to x2 and y

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2147 views
  • 1 like
  • 4 in conversation