Commit 73fdb570 by Eric Coissac

Adding a plot function for pm objects

parent a972db98
......@@ -129,7 +129,7 @@ pm = function (model,data) {
yhat,
init)
# yhat = sweep(yhat,2,b,"+")
yhat = sweep(yhat,2,b,"+")
names(scales)=attr(terms,"term.labels")
......@@ -137,8 +137,8 @@ pm = function (model,data) {
fitted.values=yhat,
residuals=Y - yhat,
call=cl,
# model=vars,
model=c(list(Y=YC),XCs),
model=vars,
# model=c(list(Y=YC),XCs),
terms = terms,
A = A_xys
)
......@@ -158,6 +158,38 @@ print.pm = function(m,...) {
invisible(m)
}
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
plot.pm = function(m,...) {
xlim = c(min(m$model[[1]][,1],m$fitted.values[,1]),
max(m$model[[1]][,1],m$fitted.values[,1])
)
ylim = c(min(m$model[[1]][,2],m$fitted.values[,2]),
max(m$model[[1]][,2],m$fitted.values[,2])
)
plot(m$model[[1]][,1:2],
xlim=xlim,ylim=ylim,
cex=0)
text(m$model[[1]][,1],m$model[[1]][,2],
rownames(m$model[[1]]),
xlim=xlim,ylim=ylim,
cex=0.8,
col="blue")
text(m$fitted.values[,1],m$fitted.values[,2],
rownames(m$fitted.values),
xlim=xlim,ylim=ylim,
cex=0.8,
col="red")
arrows(m$fitted.values[,1],m$fitted.values[,2],
m$model[[1]][,1],m$model[[1]][,2],
col="black")
}
anova.pm = function(m,...) {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment