#NEWLINE# def generate_linear( ) : #NEWLINE# #INDENT# nclust = 100 #NEWLINE# beta = np . array ( [ 1 , ( - 2 ) , 1 ] , dtype = np . float64 ) #NEWLINE# r = 0.4 #NEWLINE# rx = 0.5 #NEWLINE# re = 0.3 #NEWLINE# p = len ( beta ) #NEWLINE# OUT = open ( 'gee_linear_1.csv' , 'w' ) #NEWLINE# for i in range ( nclust ) : #NEWLINE# #INDENT# n = np . random . randint ( 3 , 6 ) #NEWLINE# x = np . random . normal ( size = ( n , p ) ) #NEWLINE# x = ( ( rx * np . random . normal ( ) ) + ( np . sqrt ( ( 1 - ( rx ** 2 ) ) ) * x ) ) #NEWLINE# x [ : , 2 ] = ( ( r * x [ : , 1 ] ) + ( np . sqrt ( ( 1 - ( r ** 2 ) ) ) * x [ : , 2 ] ) ) #NEWLINE# e = ( ( np . sqrt ( ( 1 - ( re ** 2 ) ) ) * np . random . normal ( size = n ) ) + ( re * np . random . normal ( ) ) ) #NEWLINE# y = ( np . dot ( x , beta ) + np . random . normal ( size = n ) ) #NEWLINE# for j in range ( n ) : #NEWLINE# #INDENT# OUT . write ( ( '%d,%d,' % ( i , y [ j ] ) ) ) #NEWLINE# OUT . write ( ( ',' . join ( [ ( '%.3f' % b ) for b in x [ j , : ] ] ) + '\n' ) ) #NEWLINE# #UNINDENT# #UNINDENT# OUT . close ( )