ppr
位於 stats
包(package)。 說明
擬合投影尋蹤回歸模型。
用法
ppr(x, ...)
## S3 method for class 'formula'
ppr(formula, data, weights, subset, na.action,
contrasts = NULL, ..., model = FALSE)
## Default S3 method:
ppr(x, y, weights = rep(1, n),
ww = rep(1, q), nterms, max.terms = nterms, optlevel = 2,
sm.method = c("supsmu", "spline", "gcvspline"),
bass = 0, span = 0, df = 5, gcvpen = 1, trace = FALSE, ...)
參數
formula |
指定一個或多個數字響應變量和解釋變量的公式。 |
x |
解釋變量的數字矩陣。行代表觀察值,列代表變量。不接受缺失值。 |
y |
響應變量的數字矩陣。行代表觀察值,列代表變量。不接受缺失值。 |
nterms |
最終模型中包含的項數。 |
data |
一個數據幀(或類似的:參見 |
weights |
每種情況的權重向量 |
ww |
每個響應的權重向量,因此擬合標準是 |
subset |
指定訓練樣本中使用的情況的索引向量。 (注意:如果給出,則必須命名該參數。) |
na.action |
一個函數,用於指定找到 |
contrasts |
對任何因子解釋變量進行編碼時要使用的對比。 |
max.terms |
構建模型時可選擇的最大項數。 |
optlevel |
0 到 3 之間的整數,決定 SMART 程序中優化例程的徹底性。請參閱“詳細信息”部分。 |
sm.method |
用於平滑嶺函數的方法。默認是使用 Friedman 的超級平滑器 可以縮寫。 |
bass |
超平滑的低音音調控製與自動跨度選擇一起使用(參見 |
span |
超級平滑的跨度控製(參見 |
df |
如果 |
gcvpen |
如果 |
trace |
邏輯指示每個樣條擬合是否應產生診斷輸出(關於 |
... |
要傳遞給其他方法或從其他方法傳遞的參數。 |
model |
合乎邏輯的。如果為 true,則返回模型框架。 |
細節
基本方法由 Friedman (1984) 給出,本質上與 S-PLUS 的 ppreg
使用的代碼相同。該代碼對所使用的編譯器極其敏感。
該算法首先將 max.terms
嶺項一次相加;如果它無法找到一個可以產生足夠差異的術語來添加,它將使用更少的內容。然後,它會在每一步中刪除最不重要的術語,直到留下 nterms
術語。
優化級別(參數 optlevel
)的不同之處在於在此過程中模型重新擬合的徹底程度。在 0 級,現有的山脊項不會進行改裝。在級別 1,投影方向不會重新擬合,但嶺函數和回歸係數會重新擬合。 2 級和 3 級重新調整了所有術語,並且對於一個響應來說是等效的;第 3 級更仔細地重新平衡每個步驟中每個回歸量的貢獻,因此不太可能收斂到平方和標準的鞍點。
值
包含以下組件的列表,其中許多組件供方法函數使用。
call |
匹配的調用 |
p |
解釋變量的數量(任何編碼後) |
q |
響應變量的數量 |
mu |
參數 |
ml |
參數 |
gof |
所選模型的總體殘差(加權)平方和 |
gofn |
相對於項數的總體殘差(加權)平方和,最多 |
df |
參數 |
edf |
如果 |
xnames |
解釋變量的名稱 |
ynames |
響應變量的名稱 |
alpha |
投影方向矩陣,每個脊項有一列 |
beta |
適用於嶺項的每個響應的係數矩陣:行是響應,列是嶺項 |
yb |
每個響應的加權平均值 |
ys |
使用的總體比例因子:在內部將響應除以 |
fitted.values |
擬合值,作為矩陣 if |
residuals |
殘差,作為矩陣 if |
smod |
內部工作數組,其中包括在訓練設定點評估的嶺函數。 |
model |
(僅當 |
例子
require(graphics)
# Note: your numerical values may differ
attach(rock)
area1 <- area/10000; peri1 <- peri/10000
rock.ppr <- ppr(log(perm) ~ area1 + peri1 + shape,
data = rock, nterms = 2, max.terms = 5)
rock.ppr
# Call:
# ppr.formula(formula = log(perm) ~ area1 + peri1 + shape, data = rock,
# nterms = 2, max.terms = 5)
#
# Goodness of fit:
# 2 terms 3 terms 4 terms 5 terms
# 8.737806 5.289517 4.745799 4.490378
summary(rock.ppr)
# ..... (same as above)
# .....
#
# Projection direction vectors ('alpha'):
# term 1 term 2
# area1 0.34357179 0.37071027
# peri1 -0.93781471 -0.61923542
# shape 0.04961846 0.69218595
#
# Coefficients of ridge terms:
# term 1 term 2
# 1.6079271 0.5460971
par(mfrow = c(3,2)) # maybe: , pty = "s")
plot(rock.ppr, main = "ppr(log(perm)~ ., nterms=2, max.terms=5)")
plot(update(rock.ppr, bass = 5), main = "update(..., bass = 5)")
plot(update(rock.ppr, sm.method = "gcv", gcvpen = 2),
main = "update(..., sm.method=\"gcv\", gcvpen=2)")
cbind(perm = rock$perm, prediction = round(exp(predict(rock.ppr)), 1))
detach()
來源
Friedman (1984):由 B. D. Ripley 轉換為雙精度並添加平滑樣條接口,最初用於 MASS
包。
參考
Friedman, J. H. and Stuetzle, W. (1981). Projection pursuit regression. Journal of the American Statistical Association, 76, 817-823. doi:10.2307/2287576.
Friedman, J. H. (1984). SMART User's Guide. Laboratory for Computational Statistics, Stanford University Technical Report No. 1.
Venables, W. N. and Ripley, B. D. (2002). Modern Applied Statistics with S. Springer.
也可以看看
相關用法
- R ppoints 概率圖的坐標
- R plot.stepfun 繪製階躍函數
- R pairwise.t.test 成對 t 檢驗
- R predict.smooth.spline 通過平滑樣條擬合進行預測
- R plot.profile.nls 繪製 profile.nls 對象
- R predict 模型預測
- R plot.isoreg isoreg 對象的繪圖方法
- R profile.nls 分析 nls 對象的方法
- R plot.HoltWinters HoltWinters 對象的繪圖函數
- R predict.HoltWinters 擬合 Holt-Winters 模型的預測函數
- R poly 計算正交多項式
- R proj 模型預測
- R predict.loess 預測黃土曲線或表麵
- R power.t.test 一個和兩個樣本 t 檢驗的功效計算
- R power.prop.test 比例二樣本檢驗的功效計算
- R preplot 繪圖對象的預計算
- R plot.ts 繪製時間序列對象
- R prcomp 主成分分析
- R printCoefmat 打印係數矩陣
- R plot.density 核密度估計的繪圖方法
- R profile 分析模型的通用函數
- R power.anova.test 方差檢驗平衡單向分析的功效計算
- R prop.test 等比例或給定比例檢驗
- R profile.glm 分析 glm 對象的方法
- R pairwise.prop.test 比例的成對比較
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Projection Pursuit Regression。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。