Testing my blogposting from iPhone ... Cool
Geolocate this post
Posted with LifeCast
Monday, December 29, 2008
Posted by
Vincent Vella
at
12:09 AM
0
comments
Sunday, October 19, 2008
Wednesday, July 02, 2008
SPSS Regression using Matrices
The SPSS syntax below does several linear regression calculations (model parameter values, sum of squares, F value, F test, R, Rsquare, t tests, etc) using matrices ... just change the data file and initialization part as required and off you go ......
/* ####### DATA FILE ################################################################################### */
FILE HANDLE data /NAME='c:\data\ratty2.sav'.
/* ####### INITIALIZATION AND DATA MATRIX ############################################################## */
MATRIX.
COMPUTE N=21. /* no of data rows */
COMPUTE IND_VARS=3. /* no of independet variables */
GET Y /FILE=data /VARIABLES =size. /* puts y-variable into column matrix called Y */
GET X1 /FILE=data /VARIABLES =t,z2,z3 /* put independent variables into a matrix called X1 */
/* ########## MATRIX CALCULATIONS #################################################################### */
COMPUTE j=make(N,1,1). /* Create column vector of 1's */
COMPUTE X={j,X1}. /* joins column of 1's in front of X1 columns */
COMPUTE XT=TRANSPOS(X). /* XT is the transpose of X */
COMPUTE XDX=XT*X. /* X'X */
COMPUTE IXDX=INV(XDX). /* (X'X)^ -1 */
COMPUTE BETA=IXDX*XT*y. /* BETA= ( (X'X) ^ -1)X'y */
COMPUTE BETAT=TRANSPOS(BETA).
COMPUTE YT = TRANSPOS(Y).
COMPUTE JT=TRANSPOS(J).
COMPUTE MODELSS=BETAT*XT*Y-(JT*Y)**2/N.
COMPUTE ERRSS=YT*Y-BETAT*XT*Y.
COMPUTE TOTALSS = YT*Y-(JT*Y)**2/N.
COMPUTE MMS=MODELSS/IND_VARS.
COMPUTE ERRMS=ERRSS/(N-IND_VARS-1).
COMPUTE F=MMS/ERRMS.
COMPUTE FP=1-FCDF(F,IND_VARS,N-IND_VARS-1).
COMPUTE VAR=IXDX*ERRSS.
COMPUTE VAR=VAR/(N-IND_VARS-1).
COMPUTE SE=SQRT(DIAG(VAR)).
COMPUTE TVAL=BETA/SE.
COMPUTE TVALF=TVAL&**2.
COMPUTE PVAL=1-FCDF(TVALF,1,N-IND_VARS-1).
COMPUTE TAB = {BETA,SE,TVAL,PVAL}.
COMPUTE RSQ= MODELSS/TOTALSS.
COMPUTE ADJRSQ=1-ERRMS/TOTALSS*(N-1).
/* ########### OUTPUT ######################################################################################## */
PRINT BETA.
PRINT X.
PRINT Y.
PRINT XT.
PRINT XDX.
PRINT IXDX.
PRINT MODELSS.
PRINT ERRSS.
PRINT TOTALSS.
PRINT MMS.
PRINT ERRMS.
PRINT F.
PRINT FP.
PRINT VAR.
PRINT SE.
PRINT TAB.
PRINT RSQ.
PRINT ADJRSQ.
END MATRIX.
Posted by
Vincent Vella
at
9:40 PM
0
comments
Labels: linear regression, matrix, spss, syntax
Thursday, June 26, 2008
Java Design Patterns
Today i had the pleasure to present a session at the monthly Java User Group Malta meeting ... its always a pleasure to meet other Java Developers in our community and aspiring students. Click on the post tile to link to the presentation ...
Posted by
Vincent Vella
at
11:12 PM
1 comments
Sunday, June 22, 2008
Java Web Application Properties
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
private static Properties properties;
private static ApplicationConfig config;
static {
config = new ApplicationConfig();
}
private ApplicationConfig () {
try {
InputStream in = this.getClass().getClassLoader().getResourceAsStream("config.properties");
properties = new Properties();
properties.load(in);
} catch (IOException ex) {
Logger.getLogger(ApplicationConfig.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static ApplicationConfig getApplicationConfig () {
return config;
}
public String getProperty (String propName) {
return properties.getProperty(propName, "Null");
}
}
Posted by
Vincent Vella
at
8:30 PM
1 comments
Labels: J2EE Application Settings

