# R语言使用逻辑回归Logistic、单因素方差分析anova和数据可视化分类iris鸢尾花数据集

## 方法

``````plot(predicresiduals(logit.fylab="

rl=lm(resi.fit)~bs(predict(.fit),8))

#rl=loess(repredictit.fit))

y=pree=TRUE)

segments(predict(l``````

## 结果

``````library(ggplot2)

#绘图数据

qplot(Petal.Width, Petal.Length, colour = Species,  data = irises, main = "Iris classification")``````

``````# 从模型中获得预测结果

logit.predictions <- ifelse(predict(logit.fit) > 0,'virginica', 'versicolor')

# 混淆矩阵

table(irises\[,5\],logit.predictions)``````

## 自测题

Diagnosis of Depression in Primary Care
To study factors related to the diagnosis of depression in primary care, 400 patients were randomly selected and the following variables were recorded:
DAV: Diagnosis of depression in any visit during one year of care.
0 = Not diagnosed
1 = Diagnosed
PCS: Physical component of SF-36 measuring health status of the patient.
MCS: Mental component of SF-36 measuring health status of the patient
BECK: The Beck depression score.
PGEND: Patient gender
0 = Female
1 = Male
AGE: Patient’s age in years.
EDUCAT: Number of years of formal schooling.
The response variable is DAV (0 not diagnosed, 1 diagnosed), and it is recorded in the first column of the data. The data are stored in the file final.dat and is available from the course web site. Perform a multiple logistic regression analysis of this data using SAS or any other statistical packages. This includes
estimation, hypothesis testing, model selection, residual analysis and diagnostics. Explain your findings in a 3 to 4- page report. Your report may include the following sections:
• Introduction: Statement of the problem.
• Material and Methods: Description of the data and methods that you used for the analysis.
• Results: Explain the results of your analysis in detail. You may cut and paste some of your computer
outputs and refer to them in the explanation of your results.
• Conclusion and Discussion: Highlight the main findings and discuss.
Please cut and paste the computer outputs to your report and do not include any direct computer output as an attachment
Please note that you have also the option of using a similar data set in your own field of interest.

2.面板平滑转移回归(PSTR)分析案例实现分析案例实现")