2
我正在策劃一個迴歸的結果,但不是預期的S曲線,我得到了一條直線是這樣的:Logistic迴歸圖給出一條直線,而不是S形曲線
這是,我使用的代碼:
我創建了一個範圍從原來的x軸數據的,它轉換成數據幀,然後預測並提請線。
model = glm(SHOT_RESULT~SHOT_DISTANCE,family='binomial',data = df_2shot)
summary(model)
#Eqn : P(SHOT_RESULT = True) = 1/(1 + e^-(0.306 - 0.0586(SHOT_DISTANCE)))
r = range(df_2shot$SHOT_DISTANCE) # draws a curve based on prediction
x_range = seq(r[1],r[2],1)
x_range = as.integer(x_range)
y = predict(model,data.frame(SHOT_DISTANCE = x_range),type="response")
plot(df_2shot$SHOT_DISTANCE, df_2shot$SHOT_RESULT, pch = 16,
xlab = "SHOT DISTANCE", ylab = "SHOT RESULT")
lines(x_range,y)
附註:我下面這個教程:http://www.theanalysisfactor.com/r-glm-plotting/
任何見解將不勝感激!謝謝! :)
啊,所以這只是情節的尺寸!謝謝! :) – Wboy