*By Kuya Kevin*

R can be pretty useful in doing statistics. It’s advisable for most classroom instructors to integrate this tool because it’s free and open-sourced. One of the most used tool in R is the lm() function to run a linear regression. (You can run the code ?lm for a full documentation of the function.

Say, that there have been a chemical factory accident and radiation levels (measured in Sievert) are measured at 7 separate distances from the factory. We wish to find out whether there is a linear relationship between the distance and radioactive levels; and create a prediction tool where we can forecast the radioactive levels for a given distance.

We have this data:

Distance | Radioactive level |

10 | 155 |

20 | 121 |

50 | 110 |

100 | 84 |

200 | 45 |

500 | 10 |

1000 | 4 |

We begin by writing the data in R. We can set the vector names as x and y for us to simply call those vectors:

```
x <- c(10,20,50,100,200,500,1000)
y <- c(155,121,110,84,45,10,4)
```

It has been of practice that we assign the linear regression to a variable. In our case, we name our variable “model”. The code for running the linear regression will be:

`model <-lm(y~x)`

This basically tells R to find the least squares regression model and store it in “model”. To print the summary of the regression, we simply code:

`summary(model)`

And the results are:

```
Call:
lm(formula = RadiationLevels ~ Distance)
Residuals:
1 2 3 4 5 6 7
45.019 12.350 5.342 -14.004 -39.696 -34.774 25.763
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 111.3112 16.5231 6.737 0.00109 **
Distance -0.1331 0.0383 -3.475 0.01776 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 34.21 on 5 degrees of freedom
Multiple R-squared: 0.7072, Adjusted R-squared: 0.6486
F-statistic: 12.07 on 1 and 5 DF, p-value: 0.01776
```

##### Interpreting the results

The first thing we look for in running the regression is the model itself. It can be done by using the coefficients estimate. With this, the model will be:

`Radioactive level = 111.3112 - 0.1331*Distance`

###### Testing the Overall Model

Once we have established the model, the second thing we need to assess is the validity of the overall model. This can be done by testing the F-stat of the overall model. Since we are using R, we simply look at the p-value and check whether it is lower than our set level of significance.

In this case, the p-value 0.01776 is lower than our significance level 0.05. With this fact, we have gathered sufficient evidence to conclude that the model is predicting significant proportion of the variation of radioactive levels.

###### Interpreting R-Squared

The next thing that needs to be done if we find the model as significant is to interpret the coefficient of determination. It gives us the proportion of variation accurately explained by the model in all our observations. In this case, we interpret R-squared as “70.72% of the variation in the dependent variable are accurately predicted by the model”.

##### Diagnostics

After interpreting the results of the entire regression and testing whether the model is significant, we proceed by analyzing the residuals. We can do this by simply plotting the residuals via plot() function.

`plot(model)`

The first result is the “Residual vs Fit Plot”. The thing we need to check here is that there should be no discernible pattern with the plots. Given that residuals represent the randomness in a regression, it should not form any correlation with any predictor. If a pattern is noticed, we will need a transformation in any of the variable involved since this indicates non-linearity of the relationship between the dependent and independent variable.

The second plot shows the normal QQ plot of the residuals. As an assumption in running a regression, the residuals should be approximately normal. If the points deviate significantly in the normal QQ line, this assumption will be violated making the regression results problematic.

The third plot will show the scale location. This tests the homoskedasticity assumption of regression. The main indicator is the scale line. If it’s approximately flat, we can conclude that the variation is distributed almost equally along the regression. A sloped line indicates that the distribution is not homogenous implying problems on heteroskedasticity.

The last plot will show the effects of any outlier. If some points are outside the leverage plots, we can say that an outlier significantly affected the whole model.

To show all graphs all at once, we can use the par(mfrow=c(2,2)) script:

```
par(mfrow=c(2,2))
plot(model)
```

Once all this test are satisfied, it is only by then that we conclude the results as valid.

I agree with your point of view, your article has given me a lot of help and benefited me a lot. Thanks. Hope you continue to write such excellent articles.

Reading your article helped me a lot and I agree with you. But I still have some doubts, can you clarify for me? I’ll keep an eye out for your answers.

Thank you for content. Area rugs and online home decor store. Hello Administ . Casibom , Casibom Giriş , Casibom Güncel Giriş , Casibom yeni adres . <a href="https://seowebtasarim.net/casibom/" title="Casibin

I read this paragraph completely regarding the comparison of newest and preceding technologies, it’s amazing article.

When someone writes an paragraph he/she retains the

thought of a user in his/her mind that how a

user can be aware of it. Thus that’s why this piece of

writing is perfect. Thanks!

Awesome post.

excellent points altogether, you just gained a brand new reader.

What could you suggest in regards to your post that you just

made some days in the past? Any certain?

Appreciate this post. Will try it out.

Hello, I enjoy reading all of your article post. I wanted to write a

little comment to support you.

Hi! This post couldn’t be written any better!

Reading this post reminds me of my old room mate!

He always kept talking about this. I will forward this post to him.

Pretty sure he will have a good read. Many thanks for sharing!

Woah! I’m really loving the template/theme of this site. It’s simple, yet effective.

A lot of times it’s very hard to get that “perfect balance” between user friendliness and appearance.

I must say you have done a very good job with this. Additionally, the

blog loads extremely fast for me on Firefox.

Exceptional Blog!

What’s up, every time i used to check weblog posts here early in the daylight, since i like to find out

more and more.

Hi there, I would like to subscribe for this website to take most recent

updates, so where can i do it please assist.

I just could not go away your web site prior to suggesting that I extremely enjoyed the standard information an individual provide on your

visitors? Is going to be again incessantly in order to check up on new posts

We’re a group of volunteers and opening a new scheme in our community.

Your website offered us with helpful information to work on. You’ve done a formidable task and our entire group will probably be grateful to you.

Heya i’m for the first time here. I came across this board and I find It really useful & it helped me out a lot.

I hope to give something back and aid others like you helped me.

You should take part in a contest for one of the highest quality websites

online. I most certainly will highly recommend

this web site!

It’s an amazing paragraph in support of all the internet people; they will take advantage

from it I am sure.

Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

shemale dating: women dates local no fee – video dating

prednisone 15 mg daily: https://prednisone1st.store/# prednisone 5 mg brand name

canadian pharmacy online ship to usa canadian pharmacies that deliver to the us

canadian pharmacy 24h com canadadrugpharmacy com

ed pills that work new ed treatments cures for ed

https://pharmacyreview.best/# 77 canadian pharmacy

how to get generic mobic tablets: buying cheap mobic online – where buy mobic tablets

http://cheapestedpills.com/# pills for ed

cures for ed: erection pills that work – herbal ed treatment

amoxil pharmacy amoxicillin cephalexin – can you buy amoxicillin over the counter canada

canadian pharmacy uk delivery best online canadian pharmacy

cost cheap mobic without insurance: order mobic tablets – cost cheap mobic without insurance

Prescription Drug Information, Interactions & Side.

cheap canadian pharmacy online canadian drugstore online

Medscape Drugs & Diseases.

order propecia pills propecia pill

canadian drug prices best online canadian pharmacy

compare ed drugs how to cure ed ed pills for sale

https://pharmacyreview.best/# canadian pharmacy prices

buy amoxicillin 500mg amoxicillin tablets in india – how to get amoxicillin over the counter

pills for erection: ed drugs compared – online ed pills

amoxicillin medicine over the counter: amoxicillin 250 mg capsule amoxicillin where to get

http://certifiedcanadapharm.store/# best mail order pharmacy canada

buying drugs from canada: precription drugs from canada – legitimate canadian pharmacy

http://mexpharmacy.sbs/# mexican pharmaceuticals online

cheapest online pharmacy india: india online pharmacy – top online pharmacy india

https://indiamedicine.world/# reputable indian pharmacies

mail order pharmacy india: online pharmacy india – best online pharmacy india

http://indiamedicine.world/# top 10 pharmacies in india

https://mexpharmacy.sbs/# mexico drug stores pharmacies

reputable indian online pharmacy: reputable indian online pharmacy – buy medicines online in india

http://mexpharmacy.sbs/# reputable mexican pharmacies online

purple pharmacy mexico price list: mexican rx online – mexican rx online

https://mexpharmacy.sbs/# п»їbest mexican online pharmacies

https://stromectolonline.pro/# price of ivermectin

buy cheap generic zithromax: where can i get zithromax over the counter – generic zithromax 500mg india

https://azithromycin.men/# buy azithromycin zithromax

zithromax: how to get zithromax over the counter – zithromax capsules australia

http://stromectolonline.pro/# ivermectin 3 mg

where can i buy neurontin online: medicine neurontin – neurontin brand name 800mg

paxlovid price: paxlovid covid – paxlovid pharmacy

Paxlovid over the counter: Paxlovid over the counter – paxlovid for sale

https://paxlovid.top/# Paxlovid buy online

http://lisinopril.pro/# buy lisinopril online uk

http://ciprofloxacin.ink/# antibiotics cipro

https://lisinopril.pro/# prinivil 5 mg tablets

http://lipitor.pro/# lipitor 10 mg cost

http://ciprofloxacin.ink/# buy cipro

https://indiapharmacy.cheap/# buy prescription drugs from india

best online pharmacy india top 10 online pharmacy in india top online pharmacy india

http://certifiedcanadapills.pro/# trustworthy canadian pharmacy

js加密 hello my website is js加密

hubbud dunya hello my website is hubbud dunya

slot pistol4d hello my website is slot pistol4d

arena678 alternatif hello my website is arena678 alternatif

austria hello my website is austria

Santoso hello my website is Santoso

black swan hello my website is black swan

hokihoki88 slot hello my website is hokihoki88 slot

yellow plush hello my website is yellow plush

birds sing their cheerful melodies in the morning go Be your own hero, it’s cheaper than a movie ticket

canadian pharmacy sildenafil viagra alternatives over the counter viagra alternative

viagra connect walmart viagra over the counter viagra cost

Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.

mexico drug stores pharmacies: mexican mail order pharmacies – reputable mexican pharmacies online

generic viagra walmart buying viagra viagra 50 mg

indianpharmacy com: pharmacy website india – top 10 pharmacies in india

safe canadian pharmacies: canadian pharmacies compare – canada pharmacy online

http://onlineapotheke.tech/# online apotheke deutschland

http://esfarmacia.men/# farmacias baratas online envГo gratis

https://edapotheke.store/# gГјnstige online apotheke

Acheter kamagra site fiable

https://itfarmacia.pro/# farmaci senza ricetta elenco