dim a$(1000,1000) dim randnum(1000) dim randnum2(1000) dim av1(1000) dim av2(1000) dim avtot(1000) dim score1(1000) dim score2(1000) dim scoretot(1000) numsplits=1000 Rem Count the number of rows and columns in the comma-delimited text file we're inputting Rem The csv files input here DON'T have a comma at the end of the line filedialog "Open","*.txt",file$ if file$="" then end open file$ for input as #f 'open "g:\data\funcfirstques.txt" for input as #f Rem The next lines of code read in each line from the comma delimited file, and count the lines. while not(eof(#f)) line input #f, a$ i=i+1 wend close #f nrows=i Rem Now we're going to take the last line of the file, make a little file out of it, and count the number of variables in it. Rem Here we write that one line to a file called junk.txt. open "g:\data\junk.txt" for output as #1 print#1, a$ close #1 Rem Now we open that file, input each comma-delimited variable, and count as we go. open "g:\data\junk.txt" for input as #1 while not(eof(#1)) input #1, b$ k=k+1 wend close #1 rem We're not going to subtract 1 from k, the count of columns, because rem when there is not a comma at the end of the line, the line feed appears to be input as one more a$. ncolumns=k Print "nrows= "; nrows print "ncolumns=";ncolumns ' Now let's check to make sure that the number of entries in our table equals the number that it ' should equal. 'Let's read the number of entries in our data file. open file$ for input as #f while not(eof(#f)) input#f, c$ m=m+1 wend close#f nentries=m 'Let's make sure the number of entries equals the number of rows * (number of columns+1) ' The reason for adding 1 to the number of columns is that the line feeds are also counted as entries print "nentries=";nentries if nentries=nrows*(ncolumns) then print "Columns, rows, and entries check; we're good to go." else print "Columns, rows, and entries don't check; please look at your data file to make sure each line has equal no. of entries." end end if Rem Now, knowing the number of rows and columns, we're going to read the data file into an array, a$(i,j) Rem where the order is row, column. open file$ for input as #f for i =1 to nrows rem In the next line, we're not using ncolumns+1 because of the lack of comma at end of line for j=1 to ncolumns input#f, a$(i,j) next j next i close #f rem Now let's make sure we read the file in correctly. for i=1 to nrows for j=1 to ncolumns if j<>ncolumns then ' print a$(i,j);","; else ' print a$(i,j);chr$(10) end if next j next i nfirsthalf=int(ncolumns/2) nsechalf=ncolumns-nfirsthalf sumr=0 sumsteppedr=0 Rem below begins the loop where we compute the correlation with a number of random splits. for split=1 to numsplits firstsofar=0 sum1=0 count1=0 sum2=0 count2=0 [pickasplit] ' Now we're going to pick a random way of dividing the items into two halves. ' We're going to put int(ncolumns/2) items into the first half, and the rest into the second half. ' That means that if there is an even number of items, half go into the first half and half to the second. ' If there is an odd number, the smaller number of items go into the first half and the larger number to the second. 'The variables first$(i), where i goes from 1 to nfirsthalf, will hold the values in the first set. 'The variables second$(i), where i goes from 1 to nsechalf, will hold the values in the second set. 'When we separate the ncolumns integers into two sets, the integers we get will be 'used to designate the j values of the a$(i,j) variables that will become first$(i) and second$(i). for i=1 to nfirsthalf randnum(i)=int(ncolumns*rnd(1))+1 rem Now let's check to see that the column number isn't already spoken for. rem firstsofar is the number of keepers we've got so far [checktaken] taken$="no" for q=1 to firstsofar if randnum(i)=randnum(q) then taken$="yes" next q if taken$="yes" then randnum(i)=int(ncolumns*rnd(1))+1:goto [checktaken] rem randnum(i) is a keeper if we get here ' print "Keeper is";randnum(i) firstsofar=firstsofar+1 next i rem now let's check to see if we've divided the ncolumns randomly for the first half at least for i=1 to nfirsthalf 'print randnum(i) next Rem now let's take the ncolumns integers and designate the ones not already chosen as randnum2(i) Rem where i goes from 1 to nsechalf. Rem We'll just go from 1 to nsechalf, and check to see if each of these is taken. Rem Each number that isn't already taken is assigned to randnum2(i). j=0 for i=1 to ncolumns taken$="no" for q=1 to nfirsthalf if randnum(q)=i then taken$="yes" next q if taken$="no" then j=j+1 randnum2(j)=i end if next i Rem now let's check to see if the item numbers for the second half were assigned correctly. for i=1 to nsechalf 'print "randnum2="; randnum2(i) next i Rem Now we've got nfirsthalf item numbers in the first set, and nsechalf in the second set. Rem These numbers constitute item numbers, where each row is numbered from 1 to ncolumns. Rem Now we're going to compute averages for the first half and the second half. Rem We'll do this by averaging the numbers that are nonmissing, and leaving out from the rem averaging the numbers that are missing, which are labeled "n." REm Here goes the averaging for the first half. sum1=0 count1=0 for z=1 to nrows sum1=0 count1=0 For i=1 to nfirsthalf rem we're going to call t the column number t=randnum(i) if a$(z,t)<>"n" then sum1=sum1+val(a$(z,t)):count1=count1+1 next i if count1=0 then print "a split where all were missing! line number=";z:count1=1 av1(z)=sum1/count1 score1(z)=av1(z)*nfirsthalf next z Rem Here goes the averaging for the second half. sum2=0 count2=0 for z=1 to nrows sum2=0 count2=0 for i=1 to nsechalf rem t is still the column number t=randnum2(i) if a$(z,t)<>"n" then sum2=sum2+val(a$(z,t)):count2=count2+1 next i av2(z)=sum2/count2 score2(z)=av2(z)*nsechalf next z Rem Let's compute a score for the whole test, for each person, called scoretot() for z=1 to nrows scoretot(z)=score1(z)+score2(z) 'print "score1=";score1(z);"score2=";score2(z);"scoretot=";scoretot(z) next z Rem Now we're going to compute the split-half correlation for the split we used on this round. REm We do this by computing the Pearson corr, the s for the first half, the s for second half, and s for total test sumxy=0 sumx=0 sumy=0 sumx2=0 sumy2=0 sumscoretot2=0 sumscoretot=0 for i=1 to nrows sumxy=sumxy+score1(i)*score2(i) sumx=sumx+score1(i) sumy=sumy+score2(i) sumx2=sumx2+(score1(i))^2 sumy2=sumy2+(score2(i))^2 sumscoretot2=sumscoretot2+scoretot(i)^2 sumscoretot=sumscoretot+scoretot(i) next i r=(sumxy-sumx*sumy/nrows)/((sumx2-sumx^2/nrows)*(sumy2-sumy^2/nrows))^.5 sdforx=((1/nrows)*(sumx2-sumx^2/nrows))^.5 sdfory=((1/nrows)*(sumy2-sumy^2/nrows))^.5 varfortot=((1/nrows)*(sumscoretot2-sumscoretot^2/nrows)) rem let's step up the r and accumulate the sum of the stepped up r's. rem the following line is the spearman-brown formula, which has been supplanted by the Flanagan and Rulon formula steppedrspear=(2*r)/(1+r) rem Here we go with Flanagan and Rulon formula for stepping up 'print "sdforx=";sdforx;" sdfory=";sdfory;" varfortot=";varfortot steppedrrulon=4*r*sdforx*sdfory/varfortot sumsteppedrspear=sumsteppedrspear+steppedrspear sumsteppedrrulon=sumsteppedrrulon+steppedrrulon next split rem now let's report the average r avsteppedrspear=sumsteppedrspear/numsplits Print "average of stepped up r's, using Spearman method=";avsteppedrspear avsteppedrrulon=sumsteppedrrulon/numsplits Print "average of stepped up r's, using Rulon method="; avsteppedrrulon Rem Now we're going to compute alpha assuming no missing values in the data set Rem by a standard formula, so that we can compare the value with what we get rem by the averaging of stepped up split half reliabilities. Rem varfortot is already the variance of the total test. REm ncolumns is the number of items in the test. rem now we're going to compute the variance of each item and sum the variances sumvariances=0 For i = 1 to ncolumns sumfirsts=0 sumsq=0 variance=0 for j=1 to nrows sumfirsts=sumfirsts+val(a$(j,i)) sumsq=sumsq+(val(a$(j,i)))^2 next j sfs=sumfirsts^2 variance=(1/nrows)*(sumsq-sfs/nrows) 'print "variance(";i;")=";variance sumvariances=sumvariances+variance next i for i=1 to ncolumns mean=0 sumdevs2=0 sumfirsts=0 for j=1 to nrows sumfirsts=sumfirsts+val(a$(j,i)) next j mean=sumfirsts/nrows for j=1 to nrows sumdevs2=sumdevs2+(val(a$(j,i))-mean)^2 next j sumvariance=sumvariance+sumdevs2/nrows next i Rem now we compute alpha alphatrad=(ncolumns/(ncolumns-1))*(1-sumvariances/varfortot) 'print "sumvariances=";sumvariances 'print "sumvariance=";sumvariance; "varfortot=";varfortot print "alphatrad="; alphatrad end