선형 회귀
lm() 함수를 사용하면 단순 선형 회귀를 수행할 수 있어요. 이 연습 문제에서는 shuckedWeight로 age를 설명(또는 예측)하는 모델을 적합해 보겠습니다. 모델 결과를 객체로 저장한 뒤, 그 출력 객체에서 coefficients 같은 요소를 표시해 볼 거예요.
또한 모델 객체에 대해 summary()를 실행하고, 그 출력을 다른 객체에 저장해 보겠습니다. 이 요약 객체에는 r.squared와 adj.r.squared처럼 모델 적합도와 관련된 요소가 들어 있어요. abaloneKeep 데이터셋은 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
SAS 사용자를 위한 R
연습 안내
lm()을 사용해 shucked weight로 age를 설명하는 단순 선형 회귀를 수행하세요. 출력을lmshucked로 저장하세요.- 절편과 기울기 계수를 확인하기 위해
lmshucked에서coefficients요소를 표시하세요. lmshucked에 대해summary()를 실행하고 출력을smrylmshucked로 저장하세요.- 요약 출력 객체
smrylmshucked에서r.squared와adj.r.squared요소를 표시하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Run lm() of age by shuckedWeight, save output as lmshucked
lmshucked <- lm(___ ~ ___, data = ___)
# Display coefficients element from lmshucked
___
# Save summary() output of lmshucked as smrylmshucked
___
# Show r.squared and adj.r.squared elements of smrylmshucked
___
___